squashed commit of private hostlib-resource branch
[tangerine.git] / test / setfilesize.c
bloba2fa2ac50ac045e99ebc47c72c4f3a3ee122e53a
1 #include <exec/types.h>
2 #include <dos/dosextens.h>
3 #include <dos/bptr.h>
4 #include <proto/exec.h>
5 #include <proto/dos.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <stdlib.h>
10 int main(int argc, char **argv) {
11 BPTR fh;
12 LONG size;
14 if (argc != 3) {
15 printf("usage: %s filename newsize\n", argv[0]);
16 return 1;
19 fh = Open(argv[1], MODE_READWRITE);
20 if (fh == NULL) {
21 printf("Open failed: %ld\n", IoErr());
22 return 0;
25 size = SetFileSize(fh, atol(argv[2]), OFFSET_BEGINNING);
26 if (size < 0) {
27 printf("SetFileSize: %ld\n", IoErr());
28 return 0;
31 printf ("new size is %ld bytes\n", size);
33 Close(fh);
35 return 0;