2 Copyright © 1995-2001, 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 *****************************************************************************/
50 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
52 /* Get pointer to filehandle. */
53 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(file
);
55 /* The file must be in write mode. */
56 if( fh
->fh_Flags
& FHF_WRITE
)
58 /* Handle append mode. */
59 if( fh
->fh_Flags
& FHF_APPEND
)
61 InternalSeek( fh
, 0, OFFSET_END
, DOSBase
);
64 return InternalFlush( fh
, DOSBase
);
66 else if( fh
->fh_Pos
< fh
->fh_End
)
68 int offset
= fh
->fh_Pos
- fh
->fh_End
;
70 fh
->fh_Pos
= fh
->fh_End
= fh
->fh_Buf
;
72 /* Read mode. Try to seek back to the current position. */
73 if( InternalSeek( file
, offset
, OFFSET_CURRENT
, DOSBase
) < 0 )