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

Function do_copy

lib_acl_cpp/samples/dircopy/main.cpp:262–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262static void do_copy(const acl::string& from, const acl::string& to)
263{
264 acl::scan_dir scan;
265 if (scan.open(from.c_str()) == false)
266 {
267 logger_error("open path: %s error: %s",
268 from.c_str(), acl::last_serror());
269 return;
270 }
271
272 const char* name;
273 bool is_file;
274 int nfiles = 0, ndirs = 0, nfiles_copied = 0, ndirs_copied = 0;
275 while ((name = scan.next(false, &is_file)) != NULL)
276 {
277 SKIP(name);
278
279 if (is_file)
280 {
281 if (cmp_copy(scan, name, to, &nfiles_copied) == false)
282 {
283 printf(">>cm_copy failed, name: %s\r\n", name);
284 break;
285 }
286 nfiles++;
287 }
288 else if (check_dir(scan, to, &ndirs_copied) == false)
289 {
290 printf(">>check_dir failed, name: %s\r\n", name);
291 break;
292 }
293 else
294 ndirs++;
295
296 if ((nfiles + ndirs) % 100 == 0)
297 {
298 printf("current file count: copied %d / scaned %d, "
299 "dir count: copied %d / scaned %d\r",
300 nfiles_copied, nfiles, ndirs_copied, ndirs);
301 fflush(stdout);
302 }
303 }
304
305 printf("total file count: copyied %d / scaned %d, dir count: "
306 "copied %d / scaned %d\r\n", nfiles_copied, nfiles,
307 ndirs_copied, ndirs);
308}
309
310static void usage(const char* procname)
311{

Callers 1

mainFunction · 0.85

Calls 6

cmp_copyFunction · 0.85
check_dirFunction · 0.70
last_serrorFunction · 0.50
openMethod · 0.45
c_strMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…