ReactOS 0.4.16-dev-2104-gb84fa49
rcopy.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <string.h>
3#include <stdlib.h>
4
5#if defined (__DJGPP__) || defined (__WIN32__)
6#define DOS_PATHS
7#else
8#define UNIX_PATHS
9#endif
10
11char* convert_path(char* origpath)
12{
13 char* newpath;
14 int i;
15
16 newpath = strdup(origpath);
17
18 i = 0;
19 while (newpath[i] != 0)
20 {
21#ifdef UNIX_PATHS
22 if (newpath[i] == '\\')
23 {
24 newpath[i] = '/';
25 }
26#else
27#ifdef DOS_PATHS
28 if (newpath[i] == '/')
29 {
30 newpath[i] = '\\';
31 }
32#endif
33#endif
34 i++;
35 }
36 return(newpath);
37}
38
39#define TRANSFER_SIZE (65536)
40
41int main(int argc, char* argv[])
42{
43 char* path1;
44 char* path2;
45 FILE* in;
46 FILE* out;
47 char* buf;
48 int n_in;
49 int n_out;
50
51 if (argc != 3)
52 {
53 fprintf(stderr, "Too many arguments\n");
54 exit(1);
55 }
56
59
60 in = fopen(path1, "rb");
61 if (in == NULL)
62 {
63 perror("Cannot open input file");
64 exit(1);
65 }
66
67
68
69 out = fopen(path2, "wb");
70 if (out == NULL)
71 {
72 perror("Cannot open output file");
73 fclose(in);
74 exit(1);
75 }
76
78
79 while (!feof(in))
80 {
81 n_in = fread(buf, 1, TRANSFER_SIZE, in);
82 n_out = fwrite(buf, 1, n_in, out);
83 if (n_in != n_out)
84 {
85 perror("Failed to write to output file\n");
86 free(buf);
87 fclose(in);
88 fclose(out);
89 exit(1);
90 }
91 }
92 exit(0);
93}
static int argc
Definition: ServiceArgs.c:12
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
void CDECL perror(const char *str)
Definition: errno.c:337
int CDECL fclose(FILE *file)
Definition: file.c:3757
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
size_t CDECL fread(void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4406
int CDECL feof(FILE *file)
Definition: file.c:3803
FILE *CDECL fopen(const char *path, const char *mode)
Definition: file.c:4310
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4129
#define stderr
static char * strdup(const char *buf)
Definition: string.h:83
int main()
Definition: test.c:6
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const WCHAR path1[]
Definition: path.c:28
static const WCHAR path2[]
Definition: path.c:29
#define argv
Definition: mplay32.c:18
char * convert_path(char *origpath)
Definition: rcopy.c:11
#define TRANSFER_SIZE
Definition: rcopy.c:39
#define exit(n)
Definition: config.h:202
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383