r4722@vps: verhaegs | 2007-05-06 13:11:19 -0400
[cake.git] / rom / dos / lockrecord.c
blob68e7ec1d28737e5a5eecff3f534992303aa25a61
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <dos/filesystem.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH5(BOOL, LockRecord,
20 /* SYNOPSIS */
21 AROS_LHA(BPTR , fh, D1),
22 AROS_LHA(ULONG, offset, D2),
23 AROS_LHA(ULONG, length, D3),
24 AROS_LHA(ULONG, mode, D4),
25 AROS_LHA(ULONG, timeout, D5),
27 /* LOCATION */
28 struct DosLibrary *, DOSBase, 45, Dos)
30 /* FUNCTION
32 Lock a portion of a file for exclusive access. A timeout may be specified
33 which is the maximum amount of time to wait for the record to be available.
35 INPUTS
37 fh -- file handle for the file to lock a record of
38 offset -- starting position of the lock
39 length -- length of the record in bytes
40 mode -- lock type
41 timeout -- timeout interval measured in ticks (may be 0)
43 RESULT
45 Success/failure indicator.
47 NOTES
49 Record locks are cooperative, meaning that they only affect other calls
50 to LockRecord().
52 EXAMPLE
54 BUGS
56 SEE ALSO
58 LockRecords(), UnLockRecord()
60 INTERNALS
62 *****************************************************************************/
64 AROS_LIBFUNC_INIT
66 struct IOFileSys iofs;
67 struct FileHandle *fileH = fh;
69 if (fh == NULL)
71 return DOSFALSE;
74 InitIOFS(&iofs, FSA_LOCK_RECORD, DOSBase);
76 iofs.IOFS.io_Device = fileH->fh_Device;
77 iofs.IOFS.io_Unit = fileH->fh_Unit;
79 iofs.io_Union.io_RECORD.io_Offset = offset;
80 iofs.io_Union.io_RECORD.io_Size = length;
81 iofs.io_Union.io_RECORD.io_RecordMode = mode;
82 iofs.io_Union.io_RECORD.io_Timeout = timeout;
84 DosDoIO(&iofs.IOFS);
86 SetIoErr(iofs.io_DosError);
88 if (iofs.io_DosError != 0)
90 return DOSFALSE;
93 return DOSTRUE;
95 AROS_LIBFUNC_EXIT
96 } /* LockRecord */