• 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: Locking Files?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Locking Files?


  • Subject: Re: Locking Files?
  • From: Vince DeMarco <email@hidden>
  • Date: Fri, 7 Sep 2001 11:36:27 -0700

On Friday, September 7, 2001, at 02:16 am, Josh M. Hurd wrote:

Hello list,

Is it possible to lock and unlock files in Cocoa? I checked the NSFileManger docs but it doesn't seem to mention anything about locking files. I also checked the Functions section for Foundation and AppKit. Do I have to resort to using Carbon functions? I'd rather not if possible.

man flock


FLOCK(2) System Programmer's Manual FLOCK(2)

NAME
flock - apply or remove an advisory lock on an open file

SYNOPSIS
#include <sys/file.h>
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
#define LOCK_NB 4 /* don't block when locking */
#define LOCK_UN 8 /* unlock */

int
flock(int fd, int operation)

DESCRIPTION
Flock() applies or removes an advisory lock on the file associated with
the file descriptor fd. A lock is applied by specifying an operation pa-
rameter that is one of LOCK_SH or LOCK_EX with the optional addition of
LOCK_NB. To unlock an existing lock operation should be LOCK_UN.

Advisory locks allow cooperating processes to perform consistent opera-
tions on files, but do not guarantee consistency (i.e., processes may
still access files without using advisory locks possibly resulting in in-
consistencies).


References: 
 >Locking Files? (From: "Josh M. Hurd" <email@hidden>)

  • Prev by Date: Sound documentation (Re: Search for "playscore" (NeXT) to play ".score" files in OS X)
  • Next by Date: Adding/removing menus to/from menu bar (was: Problems with NSMenu...)
  • Previous by thread: Locking Files?
  • Next by thread: Re: Locking Files?
  • Index(es):
    • Date
    • Thread