arch/ppc-sam440: No more need for the Parthenope hack
[AROS.git] / rom / dos / internalflush.c
blobee3992e9ebba4ee96a1349a55de5d2ccc2603365
1 /*
2 Copyright © 2002-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <proto/dos.h>
8 #include <aros/debug.h>
10 #include "dos_intern.h"
12 LONG InternalFlush( struct FileHandle *fh, struct DosLibrary *DOSBase )
14 LONG position;
16 /* Make sure the input parameters are sane. */
17 ASSERT_VALID_PTR( fh );
18 ASSERT_VALID_PTR( BADDR(fh->fh_Buf) );
20 ASSERT(fh->fh_End > 0);
21 ASSERT(fh->fh_Pos >= 0);
22 ASSERT(fh->fh_Pos <= fh->fh_End );
24 /* Write the data, in many pieces if the first one isn't enough. */
25 position = 0;
27 while( position < fh->fh_Pos )
29 LONG size;
31 size = Write( MKBADDR(fh), BADDR(fh->fh_Buf) + position, fh->fh_Pos - position );
33 /* An error happened? No success. */
34 if( size < 0 )
36 fh->fh_Flags &= ~FHF_WRITE;
38 return FALSE;
41 position += size;
44 /* Reset the buffer. */
45 fh->fh_Pos = 0;
47 return TRUE;