2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
10 #include <dos/filesystem.h>
11 #include <proto/dos.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
17 #include <proto/dos.h>
22 AROS_LHA(BPTR
, file
, D1
),
25 struct DosLibrary
*, DOSBase
, 6, Dos
)
28 Close a filehandle opened with Open(). If the file was used
29 with buffered I/O the final write may fail and thus Close()
30 return an error. The file is closed in any case.
36 0 if there was an error. != 0 on success.
39 This function is identical to UnLock().
49 *****************************************************************************/
51 /*****************************************************************************
54 #include <clib/dos_protos.h>
56 AROS_LH1(BOOL, UnLock,
59 AROS_LHA(BPTR, lock, D1),
62 struct DosLibrary *, DOSBase, 15, Dos)
65 Free a lock created with Lock().
68 lock -- The lock to free
73 This function is identical to Close() - see there.
83 *****************************************************************************/
84 /*AROS alias UnLock Close */
88 /* Get pointer to filehandle */
89 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(file
);
91 /* Get space for I/O request. Use stack for now. */
92 struct IOFileSys iofs
;
94 /* The returncode defaults to OK. */
97 /* 0 handles are OK */
101 /* If the filehandle has a pending write on it Flush() the buffer. */
102 if(fh
->fh_Flags
& FHF_WRITE
)
105 /* Prepare I/O request. */
106 InitIOFS(&iofs
, FSA_CLOSE
, DOSBase
);
108 iofs
.IOFS
.io_Device
= fh
->fh_Device
;
109 iofs
.IOFS
.io_Unit
= fh
->fh_Unit
;
111 /* Send the request. No errors possible. */
114 /* Free the filehandle which was allocated in Open(), CreateDir()
116 FreeDosObject(DOS_FILEHANDLE
, fh
);