On iOS, how can an app determine if a file is no longer being written to by another process?

StackOverflow https://stackoverflow.com/questions/4674397

سؤال

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?

هل كانت مفيدة؟

المحلول 2

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).

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top