r26781@plastic: rob | 2007-06-08 22:53:47 +1000
[cake.git] / rom / dos / internalseek.c
blob4dd2b6274b6b76e3acfe00e7c23a0a60eec1d0aa
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, with error reporting */
45 do {
46 DosDoIO(&iofs.IOFS);
47 } while (iofs.io_DosError != 0 && ErrorReport(iofs.io_DosError, REPORT_STREAM, fh, NULL) == DOSFALSE);
49 return iofs.io_DosError == 0 ? (LONG) iofs.io_Union.io_SEEK.io_Offset : -1;