- Return a non-zero return code on errors.
[AROS.git] / test / dos / examinefh.c
blob47df06ef306e3b4a85121647294d4c3526ea0487
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dos.h>
7 #include <proto/dos.h>
8 #include <stdio.h>
9 #include <string.h>
11 int main(int argc, char **argv)
13 BPTR fh;
14 LONG result = RETURN_OK;
16 if (argc < 2)
18 printf("Usage: %s <file name>\n", argv[0]);
19 return RETURN_FAIL;
22 fh = Open(argv[1], MODE_OLDFILE);
24 if (fh != BNULL)
26 struct FileInfoBlock *fib;
28 printf("IsInteractive: %d\n", (int)IsInteractive(fh));
30 fib = AllocDosObject(DOS_FIB, NULL);
31 if (fib != NULL)
33 if (ExamineFH(fh, fib))
35 printf("Got FIB:\n");
36 printf("Filename = %s\n" , fib->fib_FileName);
37 printf("Protection = 0x%08X\n", (unsigned)fib->fib_Protection);
39 else
41 printf("ExamineFH() failed, ioerr = %d\n", (int)IoErr());
42 result = RETURN_FAIL;
45 if (strcasecmp(fib->fib_FileName, FilePart(argv[1])) != 0)
47 printf("File name from FIB does not match"
48 " file name from argument\n");
49 result = RETURN_ERROR;
52 FreeDosObject(DOS_FIB, fib);
54 else
56 printf("couldn't allocate fileinfoblock\n");
57 result = RETURN_FAIL;
60 Close(fh);
62 else
64 printf("Couldn't open file\n");
65 result = RETURN_FAIL;
68 return result;