File paths in FileMaker can be a bit of a pain to manage well, in that different paths are required in different situations. Mostly this is an issue on the Mac as Windows tends to have fewer options to deal with. Two issues have come up in our development work recently that can cause problems if you’re not aware of them, and I’d like to go through our solutions.

FileVault User Accounts

One of our recent BaseElements bug reports was from someone who uses FileVault on their Mac. For those who don’t know, FileVault is an option built into Mac OS X that allows you to have encrypted user folders. The OS treats FileVault user accounts as a big sparse disk image which is loaded on login and closed on logout. Protection is provided by encrypting the disk image that contains the users account folder.

The operating system is smart enough to know when to open the disk image and how it’s going to appear to the applications, so when you’re using FileMaker there should, in theory, be no difference between the two. Reality, as it often does, proves different and it’s mostly due to how FileMaker treats local user paths.

Local Paths and FileVault

For example in FileMaker the Get ( DesktopPath ) function returns :

/HDName/Users/username/Desktop/

but if you’re a FileVault user it returns :

/username/Desktop/

More importantly, FileMaker expects that any import paths you’re using match the same details. This causes issues mostly when you’re converting from an outside path to a FileMaker path and vice versa. In my case I’m using our BaseElements plugin to ask the user to select a file, and getting back whatever path the system deems appropriate to give me for the path. Regardless of whether or not you’re a FileVault user, the system paths are the same and would be something like :

/Users/username/Desktop/pathtofile

So, it’s not too difficult to imagine a Custom Function that does this conversion and can output the right path given you know if the path is on a FileVault volume or not. And then the issue is, how do you tell if the file is on a FileVault volume… there is no built in FileMaker function called “Get ( FileVaultStatus )”. I did a little research about FileVault, and it turns out there is a way to tell from the files on disk if the current user is using FileVault. From this post on Apple’s support site, I found out that every FileVault user account folder also has a matching .username folder in the /Users/ folder.

So my quick check just takes the path returned by Get ( DesktopPath ), and strips off the /Desktop/ bit, and then checks to see if there is a file called “/Users/.username”.

This is easy enough to implement in a CF but also requires a plugin that can check for the existence of files. If you’re not using a plugin it should be possible to do the same thing via Applescript.

The only other thing to be aware of is that you also check that the file path you’re using is actually on the FileVault volume ( ie inside the users folder ) and not outside it where this isn’t an issue.

Other Volumes

The other type of path you might find on the mac is to another Volume. A Volume on the mac is another disk drive in the same computer, or a shared drive mounted on the desktop. FileMaker also treats these paths slightly differently. You’ll notice in the examples above, the output that FileMaker starts the path with the volume name ( ie “HDName” above ) but doesn’t have /Volumes in front of it. If you’re on a Volume other than the one for the current user, you need to add /Volumes to the start. So something like :

/Volumes/externalDrive/folder/pathtofile

Summary

So we now have three potential Mac path types we need to be able to generate for using in out import steps :

/HDName/Users/username/Desktop/ – Local Path
/username/Desktop/ – FileVault Path
/Volumes/externalDrive/folder/pathtofile – External Volume

Plus on Windows we need to correctly convert the paths from backslash used in the local volumes to forwardslash when outputting for the plugin.

If you’ve got better things to do than write Custom Functions to solve all those issues, do no fear, we’ve done it all for you. Attached to this post is a sample file with our CFs that convert from plugin to FMP and back again.