7

I'm using FSEvents to monitor a directory of files that will have some large files copied into it. Currently FSEvents seems to be sending out a notification when I've begun copying the file, and again when it's finished copying the file. When it's a smaller file though, I only get the one event. Is there any way to check if a file is in the middle of being copied?

This is for Snow Leopard by the way.

Morgan
  • 1,765
  • 2
  • 19
  • 26
  • This question relates to another question: http://stackoverflow.com/questions/9139445/how-to-determine-if-a-file-copy-is-completed-using-cocoa/40957388#40957388 – Danil Korotenko Dec 04 '16 at 10:19

1 Answers1

3

I ended up just using lsof to check if the file is open at a kernel level. I only begin processing the file once lsof has determined that the file is no longer in use.

Morgan
  • 1,765
  • 2
  • 19
  • 26
  • 1
    this seems not to work in a sandboxed application... `lsof: can't get PID byte count: Operation not permitted` – Axel Zehden Apr 02 '15 at 13:32