1 #include <dos/rdargs.h>
2 #include <dos/dosasl.h>
4 /************************************************************************/
6 /* Written and Copyright ©1993 by Dave Schreiber. All Rights Reserved. */
8 /* This is an Amigaized version of the Unix utility with the same name. */
12 /* Touch sets the date/time of all specified files to the current date */
13 /* and time. This uses Workbench 2.0 wildcard pattern-matching, so all */
14 /* 2.0 wildcards are valid. */
16 /* To compile (SAS/C V6.0): */
19 /* Version history: */
20 /* 1.01 - Fixed an enforcer hit */
22 /* 1.00 - Initial Release. */
24 /************************************************************************/
26 #include <exec/types.h>
28 #include <exec/memory.h>
30 #include <proto/dos.h>
31 #include <proto/exec.h>
33 void touchFiles(char *pattern
);
46 char *version
="$VER: Touch V1.01 (17.7.93)";
48 char *copyright
="Copyright 1993 by Dave Schreiber. All Rights Reserved";
50 int main(int argc
, char **argv
)
56 /*Get the list of filenames/patterns*/
58 ReadArgs("FILE/A/M",args
,&ra
);
59 filenames
=(char **)args
[0];
61 /*Update the date and time of each name matching any given pattern*/
63 for(c
=0;filenames
[c
]!=NULL
;c
++)
64 touchFiles(filenames
[c
]);
66 /*Free resources allocated by ReadArgs()*/
72 void touchFiles(char *pattern
)
74 struct AnchorPath
*anchor
;
75 struct DateStamp currentDate
;
78 /*Allocate a structure required by MatchFirst()*/
79 anchor
=(struct AnchorPath
*)AllocMem(sizeof(struct AnchorPath
),MEMF_CLEAR
);
84 if(MatchFirst(pattern
,anchor
)==0)
87 origDir
=CurrentDir(anchor
->ap_Current
->an_Lock
);
88 DateStamp(¤tDate
);
89 SetFileDate(anchor
->ap_Info
.fib_FileName
,¤tDate
);
92 /*Update the rest of the files*/
93 while(MatchNext(anchor
)==0)
95 origDir
=CurrentDir(anchor
->ap_Current
->an_Lock
);
96 DateStamp(¤tDate
);
97 SetFileDate(anchor
->ap_Info
.fib_FileName
,¤tDate
);
104 FreeMem(anchor
,sizeof(struct AnchorPath
));