Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / internalflush.c
blobaf3c14304cde99d5f25e2bdfd35f839d5974c1ad
1 /*
2 Copyright © 2002, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #undef SDEBUG
7 #undef DEBUG
8 #define DEBUG 0
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 )
20 UBYTE *position;
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 )
37 LONG size;
39 size = Write( MKBADDR(fh), position, fh->fh_Pos - position );
41 /* An error happened? No success. */
42 if( size < 0 )
44 fh->fh_Flags &= ~FHF_WRITE;
46 return FALSE;
49 position += size;
52 /* Reset the buffer. */
53 fh->fh_Pos = fh->fh_Buf;
55 return TRUE;