r4722@vps: verhaegs | 2007-05-06 13:11:19 -0400
[cake.git] / rom / dos / internalseek.c
blob0040cdb4d3f40741c02ff1fd4278a6fde25d3d97
1 /*
2 Copyright © 2002-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #undef SDEBUG
7 #undef DEBUG
8 #define DEBUG 0
9 #include <aros/debug.h>
11 #include <proto/dos.h>
12 #include "dos_intern.h"
14 LONG InternalSeek
16 struct FileHandle *fh,
17 LONG position,
18 LONG mode,
19 struct DosLibrary *DOSBase
23 /* Get pointer to I/O request. Use stackspace for now. */
24 struct IOFileSys iofs;
26 /* Make sure the input parameters are sane. */
27 ASSERT_VALID_PTR( fh );
28 ASSERT
30 mode == OFFSET_BEGINNING
31 || mode == OFFSET_END
32 || mode == OFFSET_CURRENT
35 /* Prepare I/O request. */
36 InitIOFS( &iofs, FSA_SEEK, DOSBase );
38 iofs.IOFS.io_Device = fh->fh_Device;
39 iofs.IOFS.io_Unit = fh->fh_Unit;
41 iofs.io_Union.io_SEEK.io_Offset = (QUAD)position;
42 iofs.io_Union.io_SEEK.io_SeekMode = mode;
44 /* Send the request. */
45 DosDoIO( &iofs.IOFS );
47 if( iofs.io_DosError )
49 SetIoErr( iofs.io_DosError );
50 return -1;
52 else
53 return (LONG) iofs.io_Union.io_SEEK.io_Offset;