2

My question is very similar to this one: What is the optimal way to monitor changes in a directory with a kqueue()? but I'm not satisfied with the answer there.

I have a kqueue setup to be notified when a file is copied to my app's Documents directory. Of course the notification fires as soon as the copying begins, but I want to know when it's completed. Surely there's a better way than polling modification times?

Community
  • 1
  • 1
bosmacs
  • 7,341
  • 4
  • 31
  • 31

2 Answers2

1

Do you initiate the copying and have control over the filenames ? Then the easiest solution could be to just copy to a temp file and then after that rename it to it's final name.that way you would know: if this file is there-it ist no longer written to.

HeikoG
  • 1,793
  • 1
  • 20
  • 29
  • No, these are documents that are copied by the system into my app bundle's Documents directory for file sharing. – bosmacs Jan 24 '11 at 14:16
0

For now, the answer seems to be 'no', so I've resorted to polling the modification time of the file(s) in question.

If someone else is able to come up with a better answer, I'd be glad to hear it (and will un-accept this one).

bosmacs
  • 7,341
  • 4
  • 31
  • 31