move the debug folder to the top level
[AROS.git] / test / dos / examinefh.c
blob9c880e13c9fc6cdb74b34fc4de4d811d6854f7cc
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",
38 (unsigned)fib->fib_Protection);
40 else
42 printf("ExamineFH() failed, ioerr = %d\n", (int)IoErr());
43 result = RETURN_FAIL;
46 if (strcasecmp(fib->fib_FileName, FilePart(argv[1])) != 0)
48 printf("File name from FIB does not match"
49 " file name from argument\n");
50 result = RETURN_ERROR;
53 FreeDosObject(DOS_FIB, fib);
55 else
57 printf("couldn't allocate fileinfoblock\n");
58 result = RETURN_FAIL;
61 Close(fh);
63 else
65 printf("Couldn't open file\n");
66 result = RETURN_FAIL;
69 return result;