home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / seek.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.9 KB  |  113 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: seek.c,v 1.6 1997/01/27 00:36:30 ldp Exp $
  4.     $Log: seek.c,v $
  5.     Revision 1.6  1997/01/27 00:36:30  ldp
  6.     Polish
  7.  
  8.     Revision 1.5  1996/12/09 13:53:42  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.4  1996/10/24 15:50:36  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.3  1996/08/13 13:52:51  digulla
  17.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  18.     Replaced AROS_LA by AROS_LHA
  19.  
  20.     Revision 1.2  1996/08/01 17:40:57  digulla
  21.     Added standard header for all files
  22.  
  23.     Desc:
  24.     Lang: english
  25. */
  26. #include <proto/exec.h>
  27. #include <dos/filesystem.h>
  28. #include "dos_intern.h"
  29.  
  30. /*****************************************************************************
  31.  
  32.     NAME */
  33. #include <proto/dos.h>
  34.  
  35.     AROS_LH3(LONG, Seek,
  36.  
  37. /*  SYNOPSIS */
  38.     AROS_LHA(BPTR, file,     D1),
  39.     AROS_LHA(LONG, position, D2),
  40.     AROS_LHA(LONG, mode,     D3),
  41.  
  42. /*  LOCATION */
  43.     struct DosLibrary *, DOSBase, 11, Dos)
  44.  
  45. /*  FUNCTION
  46.     Changes the actual read/write position in a file and/or
  47.     reads the actual position, e.g to get the actual position
  48.     do a Seek(file,0,OFFSET_CURRENT).
  49.  
  50.     This function may fail (obviously) on certain devices such
  51.     as pipes or console handlers.
  52.  
  53.     INPUTS
  54.     file     - filehandle
  55.     position - relative offset in bytes (positive, negative or 0).
  56.     mode     - Where to count from. Either OFFSET_BEGINNING,
  57.            OFFSET_CURRENT or OFFSET_END.
  58.  
  59.     RESULT
  60.     Absolute position in bytes before the Seek(), -1 if an error
  61.     happened. IoErr() will give additional information in that case.
  62.  
  63.     NOTES
  64.  
  65.     EXAMPLE
  66.  
  67.     BUGS
  68.  
  69.     SEE ALSO
  70.  
  71.     INTERNALS
  72.  
  73.     HISTORY
  74.     29-10-95    digulla automatically created from
  75.                 dos_lib.fd and clib/dos_protos.h
  76.  
  77. *****************************************************************************/
  78. {
  79.     AROS_LIBFUNC_INIT
  80.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  81.  
  82.     /* Get pointer to filehandle */
  83.     struct FileHandle *fh=(struct FileHandle *)BADDR(file);
  84.  
  85.     /* Get pointer to process structure */
  86.     struct Process *me=(struct Process *)FindTask(NULL);
  87.  
  88.     /* Get pointer to I/O request. Use stackspace for now. */
  89.     struct IOFileSys io,*iofs=&io;
  90.  
  91.     /* Prepare I/O request. */
  92.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  93.     iofs->IOFS.io_Message.mn_ReplyPort     =&me->pr_MsgPort;
  94.     iofs->IOFS.io_Message.mn_Length     =sizeof(struct IOFileSys);
  95.     iofs->IOFS.io_Device =fh->fh_Device;
  96.     iofs->IOFS.io_Unit     =fh->fh_Unit;
  97.     iofs->IOFS.io_Command=FSA_SEEK;
  98.     iofs->IOFS.io_Flags  =0;
  99.     iofs->io_Args[0]=position<0?-1:0;
  100.     iofs->io_Args[1]=position;
  101.     iofs->io_Args[2]=mode;
  102.  
  103.     /* Send the request. */
  104.     DoIO(&iofs->IOFS);
  105.  
  106.     /* return */
  107.     if((me->pr_Result2=iofs->io_DosError))
  108.     return -1;
  109.     else
  110.     return iofs->io_Args[1];
  111.     AROS_LIBFUNC_EXIT
  112. } /* Seek */
  113.