reindent-20030715
[openafs.git] / src / config / touch.c
1 /* touch.c : Defines the entry point for the console application.*/
2 /* Copyright 2000, International Business Machines Corporation and others.
3         All Rights Reserved.
4  
5         This software has been released under the terms of the IBM Public
6         License.  For details, see the LICENSE file in the top-level source
7         directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10 #include "io.h"
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <sys/stat.h>
14 #include <process.h>
15
16 void
17 usuage()
18 {
19     printf("touch filename/Wildcard \n");
20     exit(1);
21 }
22
23 int
24 main(int argc, char *argv[])
25 {
26     int fh, fs;
27     long pos;
28     char buffer[1];
29     struct _finddata_t finfo;
30     if (argc < 2)
31         usuage();
32     fs = _findfirst(argv[1], &finfo);
33     if (fs == -1)
34         return 0;
35     do {
36
37         if ((finfo.attrib & ~_A_ARCH) != _A_NORMAL)
38             continue;
39         fh = _open(finfo.name, _S_IWRITE | _O_BINARY | _S_IREAD | _O_RDWR);
40         pos = _lseek(fh, 0l, SEEK_END);
41         _write(fh, buffer, 1);
42         _chsize(fh, pos);
43         _close(fh);
44     } while (_findnext(fs, &finfo) == 0);
45     return 0;
46 }