C:List: Compiler delint
[AROS.git] / test / dos / setfiledate.c
blob7d9c22adfce644082ddb7269208787f198d15675
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dos.h>
7 #include <proto/dos.h>
8 #include <dos/datetime.h>
10 int main(void)
12 struct DateTime curr;
13 char day[LEN_DATSTRING];
14 char time[LEN_DATSTRING];
15 char date[LEN_DATSTRING];
16 struct DateStamp stamp;
18 curr.dat_Format = FORMAT_DOS;
19 curr.dat_Flags = 0;
20 curr.dat_StrDay = day;
21 curr.dat_StrDate = date;
22 curr.dat_StrTime = time;
24 DateStamp(&curr.dat_Stamp);
25 DateToStr(&curr);
26 Printf("Current time: %s, %s, %s\n", day, date, time);
28 BPTR fh = Open("__TEST__", MODE_NEWFILE);
30 if (fh != BNULL)
32 struct FileInfoBlock *fib = AllocDosObject(DOS_FIB, NULL);
34 if (fib != NULL)
36 if (ExamineFH(fh, fib))
38 curr.dat_Stamp = fib->fib_Date;
39 DateToStr(&curr);
40 Printf("File modification time: %s, %s, %s\n", day, date, time);
42 else
43 PrintFault(IoErr(), "Examine failed");
45 Printf("Waiting 5 seconds\n");
46 Delay(5*50);
48 DateStamp(&stamp);
50 Printf("Calling SetFileDate\n");
51 if(SetFileDate("__TEST__", &stamp)) {
52 if (ExamineFH(fh, fib))
54 curr.dat_Stamp = fib->fib_Date;
55 DateToStr(&curr);
56 Printf("New file modification time: %s, %s, %s\n", day, date, time);
58 else
59 PrintFault(IoErr(), "Examine failed");
61 else
62 PrintFault(IoErr(), "SetFileDate");
64 FreeDosObject(DOS_FIB, fib);
66 else
67 PrintFault(IoErr(), "Couldn't alloc FileInfoBlock");
69 Close(fh);
70 DeleteFile("__TEST__");
72 else
73 PrintFault(IoErr(), "Couldn't create file");
75 return 0;