| 313 | } |
| 314 | |
| 315 | int main(int argc, char* argv[]) |
| 316 | { |
| 317 | int ch; |
| 318 | acl::string path_from, path_to; |
| 319 | acl::log::stdout_open(true); |
| 320 | |
| 321 | while ((ch = getopt(argc, argv, "hf:t:")) > 0) |
| 322 | { |
| 323 | switch (ch) |
| 324 | { |
| 325 | case 'h': |
| 326 | usage(argv[0]); |
| 327 | return 0; |
| 328 | case 'f': |
| 329 | path_from = optarg; |
| 330 | break; |
| 331 | case 't': |
| 332 | path_to = optarg; |
| 333 | break; |
| 334 | default: |
| 335 | break; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | if (path_from.empty() || path_to.empty()) |
| 340 | { |
| 341 | usage(argv[0]); |
| 342 | return 1; |
| 343 | } |
| 344 | |
| 345 | if (path_from == path_to) |
| 346 | { |
| 347 | logger_error("path_from(%s) == path_to(%s)", path_from.c_str(), |
| 348 | path_to.c_str()); |
| 349 | usage(argv[0]); |
| 350 | return 1; |
| 351 | } |
| 352 | |
| 353 | if (chdir(path_from.c_str()) == -1) |
| 354 | { |
| 355 | logger_error("chdir to %s error: %s", |
| 356 | path_from.c_str(), acl::last_serror()); |
| 357 | return 1; |
| 358 | } |
| 359 | |
| 360 | char path[256]; |
| 361 | if (getcwd(path, sizeof(path)) == NULL) |
| 362 | { |
| 363 | logger_error("getcwd error: %s", path); |
| 364 | return 1; |
| 365 | } |
| 366 | logger("current path: %s", path); |
| 367 | |
| 368 | do_copy(".", path_to); |
| 369 | |
| 370 | logger("enter any key to exit"); |
| 371 | getchar(); |
| 372 | |