Corrected invalid characters.
[tangerine.git] / rom / dos / setfilesize.c
blob6d5a8156239840199e438ff2534bb76ad97fec5e
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Change the size of a file.
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
10 #include <dos/filesystem.h>
11 #include "dos_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH3(LONG, SetFileSize,
20 /* SYNOPSIS */
21 AROS_LHA(BPTR, file, D1),
22 AROS_LHA(LONG, offset, D2),
23 AROS_LHA(LONG, mode, D3),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 76, Dos)
28 /* FUNCTION
29 Change the size of a file.
31 INPUTS
32 file - filehandle
33 offset - relative size
34 mode - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END
36 RESULT
37 New size of the file or -1 in case of an error.
38 IoErr() gives additional information in that case.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
48 INTERNALS
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 /* Get pointer to filehandle */
55 struct FileHandle *fh = (struct FileHandle *)BADDR(file);
57 /* Get pointer to I/O request. Use stackspace for now. */
58 struct IOFileSys iofs;
60 /* Prepare I/O request. */
61 InitIOFS(&iofs, FSA_SET_FILE_SIZE, DOSBase);
63 iofs.IOFS.io_Device = fh->fh_Device;
64 iofs.IOFS.io_Unit = fh->fh_Unit;
66 iofs.io_Union.io_SET_FILE_SIZE.io_Offset = (QUAD)offset;
67 iofs.io_Union.io_SET_FILE_SIZE.io_SeekMode = mode;
69 /* Send the request. */
70 DosDoIO(&iofs.IOFS);
72 SetIoErr(iofs.io_DosError);
74 if(iofs.io_DosError != 0)
75 return -1;
76 else
77 return (LONG)iofs.io_Union.io_SET_FILE_SIZE.io_Offset;
79 AROS_LIBFUNC_EXIT
80 } /* SetFileSize */