repo.or.cz
/
WRF.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
updated top-level README and version_decl for V4.5 (#1847)
[WRF.git]
/
var
/
da
/
da_main
/
copyfile.c
blob
eaf1c5388b92316ccc78970d30c6cacae62fa396
1
#include <stdio.h>
2
#include <stdlib.h>
3
4
int32_t
copyfile
(
char
*
ifile
,
char
*
ofile
)
5
{
6
char
buff
[
BUFSIZ
];
7
size_t
n
;
8
FILE
*
source
, *
target
;
9
10
source
=
fopen
(
ifile
,
"r"
);
11
12
if
(
source
==
NULL
)
13
{
return
-
1
; }
14
15
target
=
fopen
(
ofile
,
"wb+"
);
16
17
if
(
target
==
NULL
) {
18
fclose
(
source
);
19
return
-
1
;
20
}
21
22
while
( (
n
=
fread
(
buff
,
1
,
BUFSIZ
,
source
)) !=
0
) {
23
fwrite
(
buff
,
1
,
n
,
target
);
24
}
25
26
fclose
(
source
);
27
fclose
(
target
);
28
return
0
;
29
}