Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrcopy.c
Go to the documentation of this file.
00001 #include <stdio.h> 00002 #include <string.h> 00003 #include <stdlib.h> 00004 00005 #if defined (__DJGPP__) || defined (__WIN32__) 00006 #define DOS_PATHS 00007 #else 00008 #define UNIX_PATHS 00009 #endif 00010 00011 char* convert_path(char* origpath) 00012 { 00013 char* newpath; 00014 int i; 00015 00016 newpath = strdup(origpath); 00017 00018 i = 0; 00019 while (newpath[i] != 0) 00020 { 00021 #ifdef UNIX_PATHS 00022 if (newpath[i] == '\\') 00023 { 00024 newpath[i] = '/'; 00025 } 00026 #else 00027 #ifdef DOS_PATHS 00028 if (newpath[i] == '/') 00029 { 00030 newpath[i] = '\\'; 00031 } 00032 #endif 00033 #endif 00034 i++; 00035 } 00036 return(newpath); 00037 } 00038 00039 #define TRANSFER_SIZE (65536) 00040 00041 int main(int argc, char* argv[]) 00042 { 00043 char* path1; 00044 char* path2; 00045 FILE* in; 00046 FILE* out; 00047 char* buf; 00048 int n_in; 00049 int n_out; 00050 00051 if (argc != 3) 00052 { 00053 fprintf(stderr, "Too many arguments\n"); 00054 exit(1); 00055 } 00056 00057 path1 = convert_path(argv[1]); 00058 path2 = convert_path(argv[2]); 00059 00060 in = fopen(path1, "rb"); 00061 if (in == NULL) 00062 { 00063 perror("Cannot open input file"); 00064 exit(1); 00065 } 00066 00067 00068 00069 out = fopen(path2, "wb"); 00070 if (out == NULL) 00071 { 00072 perror("Cannot open output file"); 00073 fclose(in); 00074 exit(1); 00075 } 00076 00077 buf = malloc(TRANSFER_SIZE); 00078 00079 while (!feof(in)) 00080 { 00081 n_in = fread(buf, 1, TRANSFER_SIZE, in); 00082 n_out = fwrite(buf, 1, n_in, out); 00083 if (n_in != n_out) 00084 { 00085 perror("Failed to write to output file\n"); 00086 free(buf); 00087 fclose(in); 00088 fclose(out); 00089 exit(1); 00090 } 00091 } 00092 exit(0); 00093 } Generated on Sun May 27 2012 04:19:21 for ReactOS by
1.7.6.1
|