| 260 | } |
| 261 | |
| 262 | static 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 | |
| 310 | static void usage(const char* procname) |
| 311 | { |