Hint added.
[AROS.git] / workbench / c / Touch.c
blobe8f5a78daddf1b92212b9dd7ff7bd565fe6e3f01
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.1 (7.9.1999)";
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 return RETURN_OK;
68 } else {
69 /* Attempt to create the file, if needed */
70 BPTR fh = Open((STRPTR)args[0], MODE_NEWFILE);
71 if (fh) {
72 Close(fh);
73 return RETURN_OK;
77 PrintFault(IoErr(), NULL);
79 return RETURN_FAIL;