move the debug folder to the top level
[AROS.git] / test / dos / filetest.c
blob9b48b1c168dfb5446efe33583e30cad39dea79a3
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/dos.h>
7 #include <clib/exec_protos.h>
8 #include <dos/dos.h>
9 #include <clib/dos_protos.h>
10 #include <stdio.h>
12 static void hexdump(UBYTE * data, LONG len)
14 LONG i;
16 for (i = 0; i < len; i++)
17 printf("%02X ", data[i]);
19 printf("\n");
22 int main(int argc, char **argv)
24 BPTR file;
25 UBYTE buffer[20];
26 LONG r1 = 0, r2 = 0, r3 = 0, r4 = 0;
27 char *name = "testfile";
29 if (argc > 1)
30 name = argv[1];
32 file = Open(name, MODE_NEWFILE);
33 if (file)
35 r1 = Write(file, "hello, world\n", 13);
36 r2 = Seek(file, 0, OFFSET_BEGINNING);
37 r3 = Read(file, buffer, 19);
38 r4 = Close(file);
40 if (r3 >= 0)
41 buffer[r3] = 0;
43 printf("Results: %d %d %d %d \'%s\'\n", (int)r1, (int)r2, (int)r3,
44 (int)r4, buffer);
45 hexdump(buffer, r3);
47 return 0;