How can my Cocoa app be notified when the user empties the trash?

You'll probably have to end up watching ~/. Trash, but there is a notification posted when the trash is emptied. Its name is com.apple.carbon.core.

DirectoryNotification (which is also posted at other times), but it doesn't seem to have anything in the userInfo. However, it does have a string as the object, so that might contain some relevant information. My quick tests seem to indicate that it doesn't.(It looks like a string that's something like FNObject 555279-101 ).

You'll probably have to end up watching ~/. Trash, but there is a notification posted when the trash is emptied. Its name is "com.apple.carbon.core.

DirectoryNotification" (which is also posted at other times), but it doesn't seem to have anything in the userInfo. However, it does have a string as the object, so that might contain some relevant information. My quick tests seem to indicate that it doesn't.(It looks like a string that's something like "FNObject 555279-101").

Thanks. I found an example of using this at github. Com/erica/GrabUpper/blob/master/grabupper.m.

Once I know that a change is possible I can check the trash for empty and respond appropriately. – Steve Weller Mar 21 at 2:56 Note also that the trash is not only at ~/. Trash; a file on an external drive is moved to /path/to/mountpoint/Trashes/uid/.

– Yuji Jun 2 at 4:34.

You can use UKKQueue to watch file change (empty thrash) notifications: cocoadev.com/index.pl?UKKQueue.

Another option is to use FNSubscribe or FNSubscribeByPath. The notification won't tell you exactly what happened, just that something happened to the directory you subscribed to.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions