diskimage: Compiler delint
[AROS.git] / test / dos / setfiledate.c
blob0c32a62c91d8fe53d14e87ddc5027a4f9687a67b
1 #include <dos/dos.h>
2 #include <proto/dos.h>
3 #include <dos/datetime.h>
5 int main(void)
7 struct DateTime curr;
8 char day[LEN_DATSTRING];
9 char time[LEN_DATSTRING];
10 char date[LEN_DATSTRING];
11 struct DateStamp stamp;
13 curr.dat_Format = FORMAT_DOS;
14 curr.dat_Flags = 0;
15 curr.dat_StrDay = day;
16 curr.dat_StrDate = date;
17 curr.dat_StrTime = time;
19 DateStamp(&curr.dat_Stamp);
20 DateToStr(&curr);
21 Printf("Current time: %s, %s, %s\n", day, date, time);
23 BPTR fh = Open("__TEST__", MODE_NEWFILE);
25 if (fh != BNULL)
27 struct FileInfoBlock *fib = AllocDosObject(DOS_FIB, NULL);
29 if (fib != NULL)
31 if (ExamineFH(fh, fib))
33 curr.dat_Stamp = fib->fib_Date;
34 DateToStr(&curr);
35 Printf("File modification time: %s, %s, %s\n", day, date, time);
37 else
38 PrintFault(IoErr(), "Examine failed");
40 Printf("Waiting 5 seconds\n");
41 Delay(5*50);
43 DateStamp(&stamp);
45 Printf("Calling SetFileDate\n");
46 if(SetFileDate("__TEST__", &stamp)) {
47 if (ExamineFH(fh, fib))
49 curr.dat_Stamp = fib->fib_Date;
50 DateToStr(&curr);
51 Printf("New file modification time: %s, %s, %s\n", day, date, time);
53 else
54 PrintFault(IoErr(), "Examine failed");
56 else
57 PrintFault(IoErr(), "SetFileDate");
59 FreeDosObject(DOS_FIB, fib);
61 else
62 PrintFault(IoErr(), "Couldn't alloc FileInfoBlock");
64 Close(fh);
65 DeleteFile("__TEST__");
67 else
68 PrintFault(IoErr(), "Couldn't create file");
70 return 0;