Avoid redefinition errors for AFS_NONFSTRANS
[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 <windows.h>
11 #include "io.h"
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <sys/stat.h>
15 #include <process.h>
16
17 #ifndef intptr_t
18 #define intptr_t INT_PTR
19 #endif
20
21 void
22 usage()
23 {
24     printf("touch filename/Wildcard \n");
25     exit(1);
26 }
27
28 int
29 main(int argc, char *argv[])
30 {
31     int fh;
32     intptr_t fs;
33     long pos;
34     char buffer[1];
35     struct _finddata_t finfo;
36     if (argc < 2)
37         usage();
38     fs = _findfirst(argv[1], &finfo);
39     if (fs == -1)
40         return 0;
41     do {
42
43         if ((finfo.attrib & ~_A_ARCH) != _A_NORMAL)
44             continue;
45         fh = _open(finfo.name, _S_IWRITE | _O_BINARY | _S_IREAD | _O_RDWR);
46         pos = _lseek(fh, 0L, SEEK_END);
47         buffer[0] = 0;
48         _write(fh, buffer, 1);
49         _chsize(fh, pos);
50         _close(fh);
51     } while (_findnext(fs, &finfo) == 0);
52     return 0;
53 }