Search code examples
objective-ccocoaiconsmacos-carbonnsworkspace

Any way to make file resource forks uncopyable by Finder?


Is there any way to make resource forks uncopyable? In particular I'm setting a custom badge icon to the files contained in a specific directory through NSWorkspace via – setIcon:forFile:options: and I'd like those badges to be lost as soon as the files gets copied outside the folder.


Solution

  • AFAIK there is no easy/standard way to make that happen...

    IF the filesystems we are talking about are based locally on the the Mac itself then you can achieve what you want by implementing a daemon (running with high priviliges). This daemon basically integrates itself into the OS (via both FSEvent and kqueue) - this way it can monitor any file activity and act accordingly (remove the badge or similar).

    For some source on how to build such a mechanism you can check this and this and this too.

    IF you want to achieve this server-side there are several mechanisms - but they solely depend on the server technology (an notification and/or hooking mechanism).