Mac help: is a dropped folder a drive/volume

I have been working on a 7-zip frontend to compress files and folders to .7z files. It works by dropping files/folders onto the window and then processing the drops.

I don’t want the (idiot) user (maybe me! ) to accidentally drop a whole bloody disc drive to be compressed. On a PC this is fine as I check the path of the file ( eg: C:\ ) and if too short I say “No no no!”. I also check if the parent is nil.

Now I am transferring this program over to my emulated Mac, and want to do the same check. Given that one might have other drives mounted, and that this is sometimes Unix with mount points and slashes in paths and sometimes Mac-like with colon separators in paths, also .dmg files mounted, I am looking for advice on how to proceed. Must I cycle through volumes and check paths, or what would be safe and fairly easy?

Thanks.

Why can’t you always check to see if Parent is nil?

Also, on the Mac, a disk’s native path will either be “/” or “/Volumes/{name}”, but checking Parent is safer.

If you want to stick with validating NativePath, this regex pattern will do it. If it matches, it’s a disk. (Again, checking to see if Parent is nil seems safer.)

^(?:/|/Volumes/[^/]+)$

Thank you very much - works a treat! :slight_smile:

I had feared that a mounted volume’s parent would be a mount point IE: not nil.

Appreciated.