2 Copyright © 2002, The AROS Development Team. All rights reserved.
10 #include <exec/types.h>
11 #include <proto/dos.h>
12 #include <aros/debug.h>
14 #include "dos_intern.h"
16 LONG
InternalFlush( struct FileHandle
*fh
, struct DosLibrary
*DOSBase
)
18 AROS_LIBBASE_EXT_DECL( struct DosLibrary
*, DOSBase
)
22 /* Make sure the input parameters are sane. */
23 ASSERT_VALID_PTR( fh
);
24 ASSERT_VALID_PTR( fh
->fh_Buf
);
25 ASSERT_VALID_PTR( fh
->fh_Pos
);
26 ASSERT_VALID_PTR( fh
->fh_End
);
28 ASSERT(fh
->fh_End
> fh
->fh_Buf
);
29 ASSERT(fh
->fh_Pos
>= fh
->fh_Buf
);
30 ASSERT(fh
->fh_Pos
<= fh
->fh_End
);
32 /* Write the data, in many pieces if the first one isn't enough. */
33 position
= fh
->fh_Buf
;
35 while( position
< fh
->fh_Pos
)
39 size
= Write( MKBADDR(fh
), position
, fh
->fh_Pos
- position
);
41 /* An error happened? No success. */
44 fh
->fh_Flags
&= ~FHF_WRITE
;
52 /* Reset the buffer. */
53 fh
->fh_Pos
= fh
->fh_Buf
;