2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Change the size of a file.
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
10 #include <dos/filesystem.h>
11 #include "dos_intern.h"
13 /*****************************************************************************
16 #include <proto/dos.h>
18 AROS_LH3(LONG
, SetFileSize
,
21 AROS_LHA(BPTR
, file
, D1
),
22 AROS_LHA(LONG
, offset
, D2
),
23 AROS_LHA(LONG
, mode
, D3
),
26 struct DosLibrary
*, DOSBase
, 76, Dos
)
29 Change the size of a file.
33 offset - relative size
34 mode - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END
37 New size of the file or -1 in case of an error.
38 IoErr() gives additional information in that case.
50 *****************************************************************************/
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. */
72 SetIoErr(iofs
.io_DosError
);
74 if(iofs
.io_DosError
!= 0)
77 return (LONG
)iofs
.io_Union
.io_SET_FILE_SIZE
.io_Offset
;