home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / dos / seek.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.7 KB  |  105 lines

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