AFP: How To Implement Record-Locking


TOPIC ---------------------------------------------

How does multi-user software (like 4th Dimension) work with regard to AFP?
Doesn't AFP provide a record-locking feature, so that the record is locked
automatically or is that part of some structure inherent in multi-user software
(like 4th Dimension)?

DISCUSSION ---------------------------------------------

The AppleTalk Filing Protocol (AFP) lets a workstation on an AppleTalk network
access files on an AFP-compatible file server. AFP specifies a remote filing
system that provides user authentication and an access-control mechanism that
supports volume- and folder-level access rights.

AFP does not provide file-locking and record-locking features to applications
automatically. File-locking may be implemented by the application if the
appropriate parameter is passed to the AFP call (FPOpenFork) made by the
application that opens the file. These parameters include:

0 Read allows the file to be read
1 Write allows the file to be written to
4 DenyRead denies others the right to read the file while this user
has it open
5 DenyWrite denies others the right to write to the file while this
user has it open

Record-locking is accomplished in a much more complicated fashion. The
application may lock a record by using the AFP command "FPByteRangeLock". To do
this, the application must calculate where in the file the record starts and
stops. This information is then passed to the "FPByteRangeLock" command and
that range in the file is locked. The record may also be unlocked by using the
"FPByteRangeLock" command.


Published Date: Feb 18, 2012