SETFILELOCK
PBSetFLock Lock a file (prevent write access)
#include <Files.h> File Manager (PBxxx)
OSErr PBSetFLock(pb, async );
ParmBlkPtr pb ; address of an 80-byte FileParam structure
Boolean async ; 0=await completion; 1=immediate return
returns Error Code; 0=no error
PBSetFLock locks an unopened file. Subsequently, the file may not be
deleted or renamed and write operations will fail.
pb is the address of an 80-byte FileParam structure. The relevant
fields are as follows:
Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE)
-> ioNamePtr StringPtr 4 18 Address of full or partial path/ filename
-> ioVRefNum short 2 22 Volume, drive, or directory reference
-> ioFVersNum SignedByte 1 26 Version (usually 0, always 0 for HFS)
<- ioResult OSErr 2 16 Error Code (0=no error, 1=not done yet)
async is a Boolean value. Use FALSE for normal (synchronous) operation
or TRUE to enqueue the request and resume control immediately. See
Async I/O.
Returns: an operating system Error Code. It will be one of:
noErr (0) No error
extFSErr (-58) External file system
fnfErr (-43) File not found
ioErr (-36) I/O error
nsvErr (-35) No such volume
vLckdErr (-46) Volume is locked
wPrErr (-44) Diskette is write-protected

Notes: PBSetFLock sets a file's lock attribute. This prevents programs from
deleting (PBHDelete), renaming (PBRename), or writing (PBWrite)
to the file. Any attempt to open the file (PBOpen) for writing will fail.
This has no affect on currently-open access paths. Thus, you can open a
file for writing, then lock it using the same parameter block. Afterward,
use PBRstFLock to unlock the file.
You can lock/unlock an entire volume via PBSetVInfo or lock a selected
portion of an open file via PBLockRange. The high-level version of this
call is SetFLock, the HFS version is PBHSetFLock. Use PBGetFInfo to
see if a file is currently locked (ioFlAttrib bit 1 is set).
Be sure to call PBFlushVol to check that the change is written to disk.