Fixed prototype for MmSetAddressRangeModified().
[reactos.git] / tools / rtouch.c
1 #include <sys/types.h>
2 #include <sys/stat.h>
3
4 #ifdef WIN32
5 #include <sys/utime.h>
6 #else
7 #include <sys/time.h>
8 #include <stdlib.h>
9 #endif
10
11 #include <fcntl.h>
12 #include <stdio.h>
13
14 char* convert_path(char* origpath)
15 {
16   char* newpath;
17   int i;
18    
19   newpath = (char *)strdup(origpath);
20    
21   i = 0;
22   while (newpath[i] != 0)
23     {
24 #ifdef UNIX_PATHS
25       if (newpath[i] == '\\')
26         {
27           newpath[i] = '/';
28         }
29 #else
30 #ifdef DOS_PATHS
31       if (newpath[i] == '/')
32         {
33           newpath[i] = '\\';
34         }
35 #endif  
36 #endif  
37       i++;
38     }
39   return(newpath);
40 }
41
42 int main(int argc, char* argv[])
43 {
44   char* path;
45   int id;
46 #ifdef WIN32
47   time_t now;
48   struct utimbuf fnow;
49 #endif
50
51   if (argc != 2)
52     {
53       fprintf(stderr, "Wrong number of arguments.\n");
54       exit(1);
55     }
56
57   path = convert_path(argv[1]);
58   id = open(path, S_IWRITE);
59   if (id < 0)
60     {
61       id = open(path, S_IWRITE | O_CREAT);
62       if (id < 0)
63         {
64           fprintf(stderr, "Cannot create file.\n");
65           exit(1);
66         }
67     }
68
69   close(id);
70
71 #ifdef WIN32
72   now = time(NULL);
73   fnow.actime = now;
74   fnow.modtime = now;
75   (int) utime(path, &fnow);
76 #else
77   (int) utimes(path, NULL);
78 #endif
79
80   exit(0);
81 }