• 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 determine if a file is completely copied?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to determine if a file is completely copied?


  • Subject: Re: How to determine if a file is completely copied?
  • From: Dave Carrigan <email@hidden>
  • Date: Tue, 17 Feb 2009 09:24:48 -0800


On Feb 17, 2009, at 9:01 AM, Gustavo Vera wrote:

That program is the Finder, but could be any other program capable of writing files to disk. Those programs will be running in any other machine in the lan most of the time. I don't know if this is of any help, but my test case files vary in size from just 30 KB to 320 MB, and probably could be even bigger.

Thanks in advance!

This make things harder?


One approach could be to poll the file using fstat(2). If the st_mtime field is changing, you can assume that the file is still being written to. If it hasn't changed in some time period T, you can assume that the copy must have completed. The value of T is up to you and is dependent on your particular situation. If you pick a value that is too small, you run the risk of false positives.

Another approach may be to adapt lsof(8) to your needs. If the file has no open filehandles, then you can assume that it is no longer being copied. I suspect that performance may be poor if you're expecting to handle many files per second; if you're only handling a few files per minute, it might be okay.

--
Dave Carrigan
email@hidden
Seattle, WA, USA

Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________

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 determine if a file is completely copied? (From: Gustavo Vera <email@hidden>)
 >Re: How to determine if a file is completely copied? (From: Dave Carrigan <email@hidden>)
 >Re: How to determine if a file is completely copied? (From: Gustavo Vera <email@hidden>)

  • Prev by Date: Re: How to determine if a file is completely copied?
  • Next by Date: RE: Attempting to get distinct values from an entity's attribute
  • Previous by thread: Re: How to determine if a file is completely copied?
  • Next by thread: Re: How to determine if a file is completely copied?
  • Index(es):
    • Date
    • Thread