2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: SetDate CLI command
16 SetDate (file | pattern) [(weekday)] [(date)] [(time)] [ALL]
20 FILE/A,WEEKDAY,DATE,TIME,ALL/S
28 Changes the the date and time of the creation or last change of a
29 file or directory. With option ALL, it changes the date and time of
30 all files and directories (and files and subdirectories to those)
31 matching the specified pattern.
32 You may use the output from Date as input to SetDate.
36 FILE -- File (or pattern) to change the date of.
38 WEEKDAY -- Specification of the day of the date. This is locale
39 sensitive, and you may use standard keywords as
40 'Tomorrow' and 'Yesterday' (in the language used, of
43 DATE -- A date described according to the locale specification
44 of the currently used language.
46 TIME -- Time string in localized format.
48 ALL -- Recurse through subdirectories.
52 Standard DOS return codes
60 Sets the date for all files and directories in the current directory
61 and its subdirectories to the current date.
73 26.12.99 SDuvan implemented
76 #include <dos/datetime.h>
77 #include <proto/dos.h>
78 #include <dos/rdargs.h>
79 #include <dos/dosasl.h>
81 enum { ARG_FILE
= 0, ARG_WEEKDAY
, ARG_DATE
, ARG_TIME
, ARG_ALL
};
87 struct AnchorPath aPath
;
89 IPTR args
[5] = { NULL
, NULL
, NULL
, NULL
, FALSE
};
93 LONG retval
= RETURN_OK
;
94 BOOL timeError
= FALSE
; /* Error in time/date specification? */
96 rda
= ReadArgs("FILE/A,WEEKDAY,DATE,TIME,ALL/S", args
, NULL
);
100 PrintFault(IoErr(), "SetDate");
104 /* Use the current time as default (if no DATE, TIME or WEEKDAY is
106 DateStamp(&dt
.dat_Stamp
);
108 dt
.dat_Flags
= DTF_FUTURE
;
109 dt
.dat_Format
= FORMAT_DEF
;
110 dt
.dat_StrDate
= (UBYTE
*)args
[ARG_DATE
];
111 dt
.dat_StrTime
= (UBYTE
*)args
[ARG_TIME
];
113 /* Change the defaults according to the user's specifications */
114 if(StrToDate(&dt
) == DOSTRUE
)
116 dt
.dat_StrDate
= (UBYTE
*)args
[ARG_WEEKDAY
];
118 if(StrToDate(&dt
) == DOSFALSE
)
126 PutStr("SetDate: Illegal DATE or TIME string\n");
131 aPath
.ap_Flags
= (BOOL
)args
[ARG_ALL
] ? APF_DOWILD
: 0;
132 aPath
.ap_BreakBits
= SIGBREAKF_CTRL_C
;
135 /* Save the current dir */
136 oldCurDir
= CurrentDir(NULL
);
137 CurrentDir(oldCurDir
);
139 error
= MatchFirst((STRPTR
)args
[ARG_FILE
], &aPath
);
143 CurrentDir(aPath
.ap_Current
->an_Lock
);
145 // VPrintf("%s", (IPTR *)&aPath.ap_Info.fib_FileName);
147 SetFileDate(aPath
.ap_Info
.fib_FileName
, &dt
.dat_Stamp
);
149 error
= MatchNext(&aPath
);
154 /* Restore the current dir */
155 CurrentDir(oldCurDir
);
159 if(error
!= ERROR_NO_MORE_ENTRIES
)
161 if(error
== ERROR_BREAK
)
162 retval
= RETURN_WARN
;
164 retval
= RETURN_FAIL
;
166 PrintFault(IoErr(), "SetDate");