2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 #include <dos/dosextens.h>
7 #include "dos_intern.h"
10 #include <aros/debug.h>
12 /*****************************************************************************
15 #include <proto/dos.h>
20 AROS_LHA(BPTR
, file
, D1
),
23 struct DosLibrary
*, DOSBase
, 60, Dos
)
26 Flushes any pending writes on the file. If the file was used
27 for input and there is still some data to read it tries to
28 seek back to the expected position.
34 != 0 on success, 0 on error. IoErr() gives additional information
47 *****************************************************************************/
51 /* Get pointer to filehandle. */
52 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(file
);
54 /* The file must be in write mode. */
55 if( fh
->fh_Flags
& FHF_WRITE
)
57 /* Handle append mode. */
58 if( fh
->fh_Flags
& FHF_APPEND
)
60 InternalSeek( fh
, 0, OFFSET_END
, DOSBase
);
63 return InternalFlush( fh
, DOSBase
);
65 else if( fh
->fh_Pos
< fh
->fh_End
)
67 int offset
= fh
->fh_Pos
- fh
->fh_End
;
69 fh
->fh_Pos
= fh
->fh_End
= fh
->fh_Buf
;
71 /* Read mode. Try to seek back to the current position. */
72 if( InternalSeek( fh
, offset
, OFFSET_CURRENT
, DOSBase
) < 0 )