How can I tell my Cocoa app when a user empties the cart?

My application puts some files in the trash, but also cancels to bring them back. I need to know if the user empties the garbage so that I can free my cancel stack.

Do I need to track file system events to achieve this, or is there an easier way?

+4
source share
3 answers

You may have to watch ~ / .Trash, but there is a notification sent when the trash is empty. His name is "com.apple.carbon.core.DirectoryNotification" (which is also published at another time), but there seems to be nothing in userInfo. However, it has a string as an object in it, so it may contain some relevant information. My quick tests seem to indicate that this is not the case. (Looks like a line, something like "FNObject 555279-101" )

+2
source

You can use UKKQueue to view file change notifications (empty trash):
http://www.cocoadev.com/index.pl?UKKQueue

+1
source

Another option is to use FNSubscribe or FNSubscribeByPath . The notification will not tell you exactly what happened, just something happened with the directory you are subscribed to.

0
source

Source: https://habr.com/ru/post/1344524/


All Articles