MCPcopy Create free account
hub / github.com/acl-dev/acl / file_copy

Function file_copy

app/wizard/file_copy.cpp:4–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "file_copy.h"
3
4bool file_copy(const char* from, const char* to)
5{
6 if (strcasecmp(from, to) == 0)
7 {
8 printf("from(%s) == to(%s)\r\n", from, to);
9 return false;
10 }
11
12 ifstream in;
13 if (in.open_read(from) == false)
14 {
15 printf("open %s error: %s\r\n", from, last_serror());
16 return false;
17 }
18
19 ofstream out;
20 if (out.open_write(to) == false)
21 {
22 printf("open %s error: %s\r\n", from, last_serror());
23 return false;
24 }
25
26 string buf;
27
28 while (!in.eof())
29 {
30 if (in.gets(buf, false) == false)
31 break;
32 if (out.write(buf) < 0)
33 {
34 printf("write to %s error: %s\r\n", to, last_serror());
35 return false;
36 }
37 }
38
39 printf("create %s ok\r\n", to);
40 return true;
41}
42
43bool files_copy(const char* name, const FILE_FROM_TO* tab,
44 const char* from_path, const char* to_path)

Callers 2

files_copyMethod · 0.85
files_copyFunction · 0.85

Calls 6

getsMethod · 0.80
last_serrorFunction · 0.50
open_readMethod · 0.45
open_writeMethod · 0.45
eofMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…