FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
file_copy_crt.c
Go to the documentation of this file.
1
/* generic C stdio file copy */
2
3
#include "
fb.h
"
4
5
#define BUFFER_SIZE 512
6
7
FBCALL
int
fb_CrtFileCopy
(
const
char
*source,
const
char
*destination )
8
{
9
FILE *src, *dst;
10
unsigned
char
buffer
[
BUFFER_SIZE
];
11
size_t
bytesread;
12
13
dst =
NULL
;
14
src = fopen(source,
"rb"
);
15
if
(!src)
16
goto
err;
17
18
dst = fopen(destination,
"wb"
);
19
if
(!dst)
20
goto
err;
21
22
while
( (bytesread = fread( buffer, 1,
BUFFER_SIZE
, src )) > 0 ) {
23
if
(fwrite( buffer, 1, bytesread, dst ) != bytesread)
24
goto
err;
25
}
26
27
if
( !feof( src ) )
28
goto
err;
29
30
fclose( src );
31
fclose( dst );
32
33
return
fb_ErrorSetNum
(
FB_RTERROR_OK
);
34
35
err:
36
if
(src) fclose( src );
37
if
(dst) fclose( dst );
38
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
39
}
rtlib
file_copy_crt.c
Generated on Thu Jan 23 2014 19:40:11 for FreeBASIC by
1.8.4