Re: open file
Re: open file
- Subject: Re: open file
- From: Chris Ridd <email@hidden>
- Date: Fri, 29 Nov 2002 14:23:06 +0000
On 29/11/02 8:56 am, Jeff Disher <email@hidden> wrote:
>
Not universally under Unix-based systems. There is a facility which
>
can be used for this (which some may argue is better than a universal
>
solution) which is the flock() function defined in <sys/file.h>.
>
Having personally never used it, I am not sure how useful it is or if
>
Cocoa file management routines use it or anything compatible with it.
>
>
You could do some testing with it to find out if nobody else on the
>
list knows for certain.
>
>
Hope that helps,
>
Jeff.
>
>
>
On Friday, November 29, 2002, at 03:39 AM, Alex Reynolds wrote:
>
>
> Is there any way with NSFileHandle or another class to test whether a
>
> file is open by another application?
>
>
>
> -Alex
On Unix the only thing that *knows* which processes have a particular file
open is the kernel - there are some tools like lsof (installed in Jaguar)
which can query the kernel for this information.
As Jeff says, Unix can do advisory locking of files using flock and fcntl,
but if a program wants to ignore advisory locks it can..
May one ask why one wanted to know this? The last person asking this turned
out to want to prevent multiple users from opening the same file so that one
user couldn't accidentally overwrite changes saved by another user. This
sparked a bit of a discussion here ;-)
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.