FolderItem.Parent is Nil if Parent is /Volumes?

Just had an odd error reported. A user is selecting a mounted drive on a Mac, and the FolderItem returned /Volumes/SSD\ Cache as the Native Path. However, I try to retrieve the parent for display info and I’m getting a NOE when I try:

FromParent = f.Parent.NativePath

In the debugger, I see:


Full Code:

f = GetFolderItem(DiskSource, FolderItem.PathTypeNative)
If f <> Nil and f.Exists Then
  // DiskSource is a string "/Volumes/SSD Cache" and f is not Nil and exists
  FromParent = f.Parent.NativePath // << NOE
  FromFolder = f.DisplayName
  // error stuff ...
End If


It has always been that way. Volumes don’t have a parent, as the volume is the root path.
Mac OS X mounts most volumes in the /Volumes folder, but that’s just a mount point, not the logical volume itself.
You can safely assume all folderitems where the parent is nil is a volume (local or remote), unless it’s the startup volume.

Another way to get the parent path is to subtract the volume name from the NativePath.

1 Like

This is what I’m going to do since I need the BSD/POSIX path, not Finder’s idea of the path.

1 Like