mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 03:03:13 +00:00
Cross-platform tools added to Makefiles.
svn path=/trunk/; revision=3061
This commit is contained in:
parent
6ab0a870c1
commit
63ea3fb94c
7 changed files with 429 additions and 22 deletions
93
freeldr/tools/rcopy.c
Normal file
93
freeldr/tools/rcopy.c
Normal file
|
@ -0,0 +1,93 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined (__DJGPP__) || defined (__WIN32__)
|
||||
#define DOS_PATHS
|
||||
#else
|
||||
#define UNIX_PATHS
|
||||
#endif
|
||||
|
||||
char* convert_path(char* origpath)
|
||||
{
|
||||
char* newpath;
|
||||
int i;
|
||||
|
||||
newpath = strdup(origpath);
|
||||
|
||||
i = 0;
|
||||
while (newpath[i] != 0)
|
||||
{
|
||||
#ifdef UNIX_PATHS
|
||||
if (newpath[i] == '\\')
|
||||
{
|
||||
newpath[i] = '/';
|
||||
}
|
||||
#else
|
||||
#ifdef DOS_PATHS
|
||||
if (newpath[i] == '/')
|
||||
{
|
||||
newpath[i] = '\\';
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
i++;
|
||||
}
|
||||
return(newpath);
|
||||
}
|
||||
|
||||
#define TRANSFER_SIZE (65536)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* path1;
|
||||
char* path2;
|
||||
FILE* in;
|
||||
FILE* out;
|
||||
char* buf;
|
||||
int n_in;
|
||||
int n_out;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf(stderr, "Too many arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
path1 = convert_path(argv[1]);
|
||||
path2 = convert_path(argv[2]);
|
||||
|
||||
in = fopen(path1, "rb");
|
||||
if (in == NULL)
|
||||
{
|
||||
perror("Cannot open input file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
out = fopen(path2, "wb");
|
||||
if (out == NULL)
|
||||
{
|
||||
perror("Cannot open output file");
|
||||
fclose(in);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
buf = malloc(TRANSFER_SIZE);
|
||||
|
||||
while (!feof(in))
|
||||
{
|
||||
n_in = fread(buf, 1, TRANSFER_SIZE, in);
|
||||
n_out = fwrite(buf, 1, n_in, out);
|
||||
if (n_in != n_out)
|
||||
{
|
||||
perror("Failed to write to output file\n");
|
||||
free(buf);
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue