I was recently wondering how Mac OS X stores thumbnails of files. After some Googling, I found out that about "resource forks", a feature apparently unique to Apple's HFS file systems.
I don't really like the idea of having resource forks around, and I would like to be able to delete them. Is there any way to access the resource forks programmatically? Various forum posts said that to see the resource fork of a file like presentation.pdf I should ls presentation.pdf/rsrc, but I haven't been able to find a file like that on my system. Is this still how it works in Snow Leopard?
I am not interested in downloading or buying some tool that does this for me. I'm comfortable with the command line, and ideally I would like a command line solution, so that I can script this.
And before I actually go through with this, I guess I should ask: is there any harm in deleting the resource forks?
It depends on what is in the resource fork. The use of resource forks has been discouraged, but there are few holdouts including alias files, custom icons (on files) and some legacy font files. You can verify if a file has a resource fork in the Terminal using "ls -l@". The resource forks are also exposed in the extended attribute APIs through the "com.apple.ResourceFork" attribute.
If you want to just remove thumbnails, you could do that from the Finder's GetInfo panel. The extended attribute APIs, like removexattr(2), will let you programmatically remove the Resource Fork.
If you're curious what's inside a resource fork you can use: "hexdump -C myfile/..namedfork/rsrc"
Hope this helps
-Don