Re: How to know a file is busy(read/write)?
Re: How to know a file is busy(read/write)?
- Subject: Re: How to know a file is busy(read/write)?
- From: Alastair Houghton <email@hidden>
- Date: Fri, 11 Jan 2008 14:53:34 +0000
On 11 Jan 2008, at 05:19, shengjun_guan (管聲俊) wrote:
Because i have one application to monitor one folder that files are
created in.
eg. file1 and file2 have been created in the folder. My application
will send the file1 and file2
to other application to open them.
In some case, file1 have been finishing created.And file2 is
creating . So, if i send the tow files for
opening to other application. file2 will open fail.
So, i want to check the file2 if is busy before i send.
There is no such thing as a "busy" file on a UNIX system. You need to
redesign your application to work in a different way. For instance,
maybe files that your application acts on could have a different
extension to the ones that are being created; renaming a file is an
atomic operation, so once you've finished writing a file, you could
then rename it to bring it to the attention of your other process.
If the source code is available for all the programs in question, you
may also be able to use advisory locks, or lock files, or even some
other mechanism (for instance, you could use a socket to send the
names of the files to process to the far end).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden