• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to know a file is busy(read/write)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >How to know a file is busy(read/write)? (From: shengjun_guan (管聲俊) <email@hidden>)
 >Re: How to know a file is busy(read/write)? (From: Horn Deric <email@hidden>)
 >RE: How to know a file is busy(read/write)? (From: shengjun_guan (管聲俊) <email@hidden>)

  • Prev by Date: User Permissin.
  • Next by Date: Re: Saving an NSDocument safely
  • Previous by thread: RE: How to know a file is busy(read/write)?
  • Next by thread: NSArrayController Key-Value Observing
  • Index(es):
    • Date
    • Thread