3

I use the FSEvent API to detect file modifications. I'm already able to detect when new files/folders are created or renamed. But I can't detect if a file was removed/deleted.
When I delete a file I get a kFSEventStreamEventFlagItemRenamed and not a kFSEventStreamEventFlagItemRemoved like I would expect.
Does anyone have experience with FSEvent API or know this problem?

Thanks

Tobi Weißhaar
  • 1,617
  • 6
  • 26
  • 35
  • Are you deleting the file from the Finder? Because that just moves it to the Trash, instead of truly deleting it. – millimoose Sep 06 '13 at 22:06
  • Yes I delete it from the Finder. But how can I detect that a file was deleted when it is just moved to the Trash? – Tobi Weißhaar Sep 06 '13 at 22:07
  • Clearly you can't. You need to detect that it was moved to the Trash if that's what you're trying to check. Can you get the path the file was moved to? (I'm not very familiar with FSEvents.) – millimoose Sep 06 '13 at 22:08
  • I just get the path of the file where the file was located – Tobi Weißhaar Sep 06 '13 at 22:11
  • Hm. After searching around I think the idea is that you should also watch the trash directories for modification and catch when a file was renamed "into" them and kinda sorta match these two events up. It's not very fortunate but them's the breaks. – millimoose Sep 06 '13 at 22:16
  • You are right. If I observe the Trash I am able to detect a delete operation. Thanks for help :) – Tobi Weißhaar Sep 06 '13 at 22:55
  • I'm having same issue, did you find a way Tobi and @millimoose without monitoring trash too? I just need to know if a folder was move-out of the directory, not necessarily "moved to trash". – Noitidart Apr 23 '15 at 09:27
  • 1
    @Noitidart If you're not looking for a way to detect a file being moved to trash, then it's clearly not the same issue - the original question is "how to detect if a file was deleted." (I.e.: "moved to the Trash.") Ask a new question, fully describing your problem, instead of unnecessarily reviving old questions. Do consider that neither me or Tobi probably kept any of the code samples we worked with one and a half years ago, and aren't necessarily of more help than anyone watching for OS X programming questions. You should only comment on answers if you want that actual answer to be clarified – millimoose Apr 27 '15 at 00:16
  • Thanks @millimoose for your reply I'll do that follow up as recommended. – Noitidart Apr 27 '15 at 03:41

0 Answers0