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"
13 #include <aros/debug.h>
15 /*****************************************************************************
18 #include <proto/dos.h>
23 AROS_LHA(BPTR
, file
, D1
),
26 struct DosLibrary
*, DOSBase
, 6, Dos
)
29 Close a filehandle opened with Open(). If the file was used
30 with buffered I/O the final write may fail and thus Close()
31 return an error. The file is closed in any case.
37 0 if there was an error. != 0 on success.
40 This function is identical to UnLock().
50 *****************************************************************************/
52 /*****************************************************************************
55 #include <clib/dos_protos.h>
57 AROS_LH1(BOOL, UnLock,
60 AROS_LHA(BPTR, lock, D1),
63 struct DosLibrary *, DOSBase, 15, Dos)
66 Free a lock created with Lock().
69 lock -- The lock to free
74 This function is identical to Close() - see there.
84 *****************************************************************************/
85 /*AROS alias UnLock Close */
89 /* Get pointer to filehandle */
90 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(file
);
92 /* Get space for I/O request. Use stack for now. */
93 struct IOFileSys iofs
;
95 /* The returncode defaults to OK. */
98 ASSERT_VALID_PTR_OR_NULL(fh
);
100 /* 0 handles are OK */
104 /* If the filehandle has a pending write on it Flush() the buffer. */
105 if(fh
->fh_Flags
& FHF_WRITE
)
108 /* Prepare I/O request. */
109 InitIOFS(&iofs
, FSA_CLOSE
, DOSBase
);
111 iofs
.IOFS
.io_Device
= fh
->fh_Device
;
112 iofs
.IOFS
.io_Unit
= fh
->fh_Unit
;
114 /* Send the request. No errors possible. */
117 /* Free the filehandle which was allocated in Open(), CreateDir()
119 FreeDosObject(DOS_FILEHANDLE
, fh
);