Added locale item (sysmon.cd)
[AROS.git] / workbench / c / Touch.c
blobf6395c37a4a90b57b3f0eac41e3e4766ea7f2d4d
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Touch CLI command.
6 Lang: english
7 */
9 /******************************************************************************
12 NAME
14 Touch
16 SYNOPSIS
18 NAME/A
20 LOCATION
24 FUNCTION
26 Sets the time stamp of the file to the current time. If the file doesn't
27 exist it will be created.
29 INPUTS
31 NAME -- The name of the file to be touched.
33 RESULT
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
43 INTERNALS
45 HISTORY
47 ******************************************************************************/
49 #include <dos/dos.h>
50 #include <proto/dos.h>
52 const TEXT version[] = "$VER: Touch 41.2 (8.8.2016)";
54 int __nocommandline;
56 int main(void)
58 IPTR args[1] = { 0 };
59 struct RDArgs *rda = ReadArgs("NAME/A", args, NULL);
61 if (rda)
63 struct DateStamp ds;
65 /* Attempt to update the file's date stamp */
66 if (SetFileDate((CONST_STRPTR)args[0], DateStamp(&ds))) {
67 FreeArgs(rda);
68 return RETURN_OK;
69 } else {
70 /* Attempt to create the file, if needed */
71 BPTR fh = Open((STRPTR)args[0], MODE_NEWFILE);
72 if (fh) {
73 Close(fh);
74 FreeArgs(rda);
75 return RETURN_OK;
78 FreeArgs(rda);
81 PrintFault(IoErr(), NULL);
82 return RETURN_FAIL;