Re: Avoid changing/moving file that's currently being written.
Christiaan Hofman <[email protected]> Wed, 28 Apr 2010 13:56:44 +0200
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Apr 28, 2010, at 13:42, Fabian Schuiki wrote: > There seems to be a file attribute, can't remember the exact letters but it's something like NSFileReferenceCount. Anyone familiar with that? > > Thanks, > Fabian NSFileReferenceCount gives the number of hard links. As hard links are virtually never used on MacOSX this will always be one with a probability of 100% (give or take a billionth or something.) This does not change when some process is writing to the file. There are various things like reference counts, locks, and such that can say whether something references a file in some particular way. They're all optional, so they all have the same property: when it's there, you know it's in use in some way or another, when it's not there you still know absolutely nothing (i.e. it could be in use or not.) So the best you can do is check some of the most relevant of those counts or locks to reduce your chances of moving a file that's in use. You will never be able to be sure. And NSFileReferenceCount is certainly not one of the most relevant ones, it's probably the most irrelevant one, so you can just ignore it. Christiaan