2 Copyright © 2002-2007, 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
)
20 /* Make sure the input parameters are sane. */
21 ASSERT_VALID_PTR( fh
);
22 ASSERT_VALID_PTR( fh
->fh_Buf
);
23 ASSERT_VALID_PTR( fh
->fh_Pos
);
24 ASSERT_VALID_PTR( fh
->fh_End
);
26 ASSERT(fh
->fh_End
> fh
->fh_Buf
);
27 ASSERT(fh
->fh_Pos
>= fh
->fh_Buf
);
28 ASSERT(fh
->fh_Pos
<= fh
->fh_End
);
30 /* Write the data, in many pieces if the first one isn't enough. */
31 position
= fh
->fh_Buf
;
33 while( position
< fh
->fh_Pos
)
37 size
= Write( MKBADDR(fh
), position
, fh
->fh_Pos
- position
);
39 /* An error happened? No success. */
42 fh
->fh_Flags
&= ~FHF_WRITE
;
50 /* Reset the buffer. */
51 fh
->fh_Pos
= fh
->fh_Buf
;