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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: setfilesize.c,v 1.4 1997/01/27 00:36:31 ldp Exp $
  4.     $Log: setfilesize.c,v $
  5.     Revision 1.4  1997/01/27 00:36:31  ldp
  6.     Polish
  7.  
  8.     Revision 1.3  1996/12/09 13:53:43  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.2  1996/10/24 15:50:37  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.1  1996/09/11 12:54:47  digulla
  17.     A couple of new DOS functions from M. Fleischer
  18.  
  19.     Desc:
  20.     Lang: english
  21. */
  22. #include <proto/exec.h>
  23. #include <dos/dosextens.h>
  24. #include <dos/filesystem.h>
  25. #include "dos_intern.h"
  26.  
  27. /*****************************************************************************
  28.  
  29.     NAME */
  30. #include <proto/dos.h>
  31.  
  32.     AROS_LH3(LONG, SetFileSize,
  33.  
  34. /*  SYNOPSIS */
  35.     AROS_LHA(BPTR, file,   D1),
  36.     AROS_LHA(LONG, offset, D2),
  37.     AROS_LHA(LONG, mode,   D3),
  38.  
  39. /*  LOCATION */
  40.     struct DosLibrary *, DOSBase, 76, Dos)
  41.  
  42. /*  FUNCTION
  43.     Change the size of a file.
  44.  
  45.     INPUTS
  46.     file   - filehandle
  47.     offset - relative size
  48.     mode   - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END
  49.  
  50.     RESULT
  51.     New size of the file or -1 in case of an error.
  52.     IoErr() gives additional information in that case.
  53.  
  54.     NOTES
  55.  
  56.     EXAMPLE
  57.  
  58.     BUGS
  59.  
  60.     SEE ALSO
  61.  
  62.     INTERNALS
  63.  
  64.     HISTORY
  65.     29-10-95    digulla automatically created from
  66.                 dos_lib.fd and clib/dos_protos.h
  67.  
  68. *****************************************************************************/
  69. {
  70.     AROS_LIBFUNC_INIT
  71.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  72.  
  73.     /* Get pointer to filehandle */
  74.     struct FileHandle *fh=(struct FileHandle *)BADDR(file);
  75.  
  76.     /* Get pointer to process structure */
  77.     struct Process *me=(struct Process *)FindTask(NULL);
  78.  
  79.     /* Get pointer to I/O request. Use stackspace for now. */
  80.     struct IOFileSys io,*iofs=&io;
  81.  
  82.     /* Prepare I/O request. */
  83.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  84.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  85.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  86.     iofs->IOFS.io_Device =fh->fh_Device;
  87.     iofs->IOFS.io_Unit   =fh->fh_Unit;
  88.     iofs->IOFS.io_Command=FSA_READ;
  89.     iofs->IOFS.io_Flags  =0;
  90.     iofs->io_Args[0]=offset<0?-1:0;
  91.     iofs->io_Args[1]=offset;
  92.     iofs->io_Args[2]=mode;
  93.  
  94.     /* Send the request. */
  95.     DoIO(&iofs->IOFS);
  96.     
  97.     /* Set error code and return */
  98.     if((me->pr_Result2=iofs->io_DosError))
  99.         return -1;    
  100.     else
  101.         return iofs->io_Args[1];
  102.     
  103.     AROS_LIBFUNC_EXIT
  104. } /* SetFileSize */
  105.