Thursday, August 18, 2005

Exotic OS X knowledge: unifying data and resource forks

Mac OS X 10.4.2 (Part 29)

I once spent a few days looking for a way to unify data and resource forks. I didn't come up with anything. So this Macintouch discussion really caught my attention:
I haven't tried this as I don't have any files on a FAT32 volume, but I believe that this technique should work. Obviously, don't throw out the component files until you've tested this solution.

1) Identify the files which are the actual resource and data forks. In Scott's case he seems to understand which is which.

2) Copy the data fork file onto an HFS volume. Let's assume that the copy will be called /Users/me/test.

3) Open the terminal app.

4) Here's the slightly tricky part. You can use the 'cp' command to copy into the resource fork directly. Assuming the resource fork's file name is

/Volumes/Fat32/file/resource.frk, use this command:
cp /Volumes/Fat32/file/resource.frk /Users/me/test/rsrc

Even though /Users/me/test is a file, not a directory, the syntax above is valid (on OS X, not other Unixes). Actually, I think as of Tiger, it's being deprecated in favor of a more extensible fork naming scheme (/Users/me/test/..namedfork/rsrc), but this still works and it's easier.

5) If you (or your applications) care, use a utility to set the new file's Creator and Type. If you're not sure what they are, just open the finder info file in a text editor- they ought to jump out at you. Alternatively, make a new data file with the relevant application, and copy the info from there. I'd probably do this step just to be sure, but most OS X apps don't care about this. The Finder won't care if the file extension is correct and unique. /Developer/Tools/SetFile is a command-line tool that will work, but there are zillions available, some for free.

No comments: