Topic : The ATARI Compendium
Author : Scott Sanders / JAY Software
Version : 1.25 (20/6/2003)
Subject : Documentation
Nodes : 1117
Index Size : 32614
HCP-Version : 6
Compiled on : Atari
@charset : UTF-8
@lang : en
@default :
@help : %About
@options : +g -i -t4 +y +z
@width : 100
View Ref-FileFopen()Fwrite()Fread()Flock() GEMDOSSyntaxLONG Flock( handle, mode, start, length )
WORD handle,mode;
LONG start,length;
Function Flock() sets or removes a lock on a portion of a file which
prevents other processes from accessing it.
Opcode 92 ($5C)
Availability Only present when '_FLK' cookie exists.
Parameters handle specifies the GEMDOS handle of the file. mode is
FLK_LOCK (0) to create a lock and FLK_UNLOCK (1) to remove
it. start specifies the byte offset from the beginning of
the file which indicates where the lock starts. length specifies the length of the lock in bytes.
Binding move.l length,-(sp)
move.l start,-(sp)
move.w mode,-(sp)
move.w handle,-(sp)
trap #1
lea 12(sp),sp
Return Value Flock() returns E_OK (0) if the call was successful, ELOCKED (-58) if an overlapping section of the file was already
locked, ENSLOCK (-59) if a matching lock was not found for
removal, or another GEMDOS error code as appropriate.
Comments To remove a lock, you must specify identical start and
length parameters as you originally set. MiNT allows locks to
be set on devices by locking their entry in 'U:\DEV\' as
shown in the example below:
handle = Fopen( "U:\DEV\MODEM1", 3 );
if( handle < 0)
return ERR_CODE; /* Unable to open. */
retcode = Flock( (WORD)handle, 0, 0, 0 ); /* Lock */
if( retcode != E_OK )
return FILE_IN_USE; /* File is already locked */
/*
* Now do device input/output.
*/
Flock( (WORD)handle, 1, 0, 0 ); /* Unlock */
Fclose( (WORD)handle );
See Also Fopen(), Fwrite(), Fread()