From d0d1b840ca291139f5eebfe7be0b5752fca3e04d Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 17 Jan 2003 19:06:15 +0000 Subject: [PATCH] make it compile on linux too svn path=/trunk/; revision=4025 --- reactos/tools/rtouch.c | 95 ++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/reactos/tools/rtouch.c b/reactos/tools/rtouch.c index b49710fd54a..2adf53c149b 100755 --- a/reactos/tools/rtouch.c +++ b/reactos/tools/rtouch.c @@ -1,68 +1,81 @@ #include #include + +#ifdef WIN32 #include +#else +#include +#include +#endif + #include #include char* convert_path(char* origpath) { - char* newpath; - int i; + char* newpath; + int i; - newpath = (char *)strdup(origpath); + newpath = (char *)strdup(origpath); - i = 0; - while (newpath[i] != 0) - { + i = 0; + while (newpath[i] != 0) + { #ifdef UNIX_PATHS - if (newpath[i] == '\\') - { - newpath[i] = '/'; - } + if (newpath[i] == '\\') + { + newpath[i] = '/'; + } #else #ifdef DOS_PATHS - if (newpath[i] == '/') - { - newpath[i] = '\\'; - } + if (newpath[i] == '/') + { + newpath[i] = '\\'; + } #endif #endif - i++; - } - return(newpath); + i++; + } + return(newpath); } int main(int argc, char* argv[]) { - char* path; - FILE* file; - time_t now; - struct utimbuf fnow; + char* path; + FILE* file; +#ifdef WIN32 + time_t now; + struct utimbuf fnow; +#endif - if (argc != 2) - { - fprintf(stderr, "Wrong number of arguments.\n"); - exit(1); - } + if (argc != 2) + { + fprintf(stderr, "Wrong number of arguments.\n"); + exit(1); + } - path = convert_path(argv[1]); - file = (FILE *)open(path, S_IWRITE); - if (file == (void*)-1) - { - file = (FILE *)open(path, S_IWRITE | O_CREAT); - if (file == (void*)-1) + path = convert_path(argv[1]); + file = (FILE *)open(path, S_IWRITE); + if (file == (void*)-1) + { + file = (FILE *)open(path, S_IWRITE | O_CREAT); + if (file == (void*)-1) { - fprintf(stderr, "Cannot create file.\n"); - exit(1); + fprintf(stderr, "Cannot create file.\n"); + exit(1); } - } + } - close(file); + close(file); - now = time(); - fnow.actime = now; - fnow.modtime = now; - (int) utime(path, &fnow); +#ifdef WIN32 + now = time(); + fnow.actime = now; + fnow.modtime = now; + (int) utime(path, &fnow); +#else + (int) utimes(path, NULL); +#endif - exit(0); + exit(0); }