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

Method file_copy

app/wizard/file_tmpl.cpp:175–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175bool file_tmpl::file_copy(const char* from, const char* to_in)
176{
177 string to_buf;
178 to_buf.format("%s/%s", path_to_.c_str(), to_in);
179
180 const char* to = to_buf.c_str();
181
182 if (strcasecmp(from, to) == 0) {
183 printf("from(%s) == to(%s)\r\n", from, to);
184 return false;
185 }
186
187 ifstream in;
188 if (!in.open_read(from)) {
189 printf("open %s error: %s\r\n", from, last_serror());
190 return false;
191 }
192
193 ofstream out;
194 if (!out.open_write(to)) {
195 printf("open %s error: %s\r\n", from, last_serror());
196 return false;
197 }
198
199 string buf;
200
201 while (!in.eof()) {
202 if (!in.gets(buf, false)) {
203 break;
204 }
205 if (out.write(buf) < 0) {
206 printf("write to %s error: %s\r\n", to, last_serror());
207 return false;
208 }
209 }
210
211 printf("create %s ok\r\n", to);
212 return true;
213}
214
215bool file_tmpl::files_copy(const char* name, const FILE_FROM_TO* tab)
216{

Callers 2

create_fiberFunction · 0.80
create_master_fiberFunction · 0.80

Calls 8

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

Tested by

no test coverage detected