M
Mark
Hi all,
This is something which has been bugging me for ages. How can I check
if a file is already in use by a different program?
It doesn't seem to matter which mode I pass to fopen, it will always
allow me to open the file. I've tried r, r+, w, w+, a, and a+ but
still the fopen call will not return null.
Basically what I'm doing is using a kqueue to watch a particular
directory to see when files are added, I'm then using the path of the
file which has just arrived as input to another program, however, I
need to be sure that the new file has completely finished
copying/downloading etc before passing it off to this other program.
What's happening just now is that the kqueue is firing as soon as the
file starts to appear in the directory and my secondary program is
being launched too early.
Can anyone offer any advice please?
Thanks in advance,
Mark
PS. If it helps to know, I'm using Mac OS X, so a platform specific
response is also fine if no ANSI/POSIX solution exists.
This is something which has been bugging me for ages. How can I check
if a file is already in use by a different program?
It doesn't seem to matter which mode I pass to fopen, it will always
allow me to open the file. I've tried r, r+, w, w+, a, and a+ but
still the fopen call will not return null.
Basically what I'm doing is using a kqueue to watch a particular
directory to see when files are added, I'm then using the path of the
file which has just arrived as input to another program, however, I
need to be sure that the new file has completely finished
copying/downloading etc before passing it off to this other program.
What's happening just now is that the kqueue is firing as soon as the
file starts to appear in the directory and my secondary program is
being launched too early.
Can anyone offer any advice please?
Thanks in advance,
Mark
PS. If it helps to know, I'm using Mac OS X, so a platform specific
response is also fine if no ANSI/POSIX solution exists.