| 632 | } |
| 633 | |
| 634 | Status LocalFileSystem::CopyFile(const std::string& src, const std::string& dest) { |
| 635 | RETURN_NOT_OK(ValidatePath(src)); |
| 636 | RETURN_NOT_OK(ValidatePath(dest)); |
| 637 | ARROW_ASSIGN_OR_RAISE(auto sfn, PlatformFilename::FromString(src)); |
| 638 | ARROW_ASSIGN_OR_RAISE(auto dfn, PlatformFilename::FromString(dest)); |
| 639 | // XXX should we use fstat() to compare inodes? |
| 640 | if (sfn.ToNative() == dfn.ToNative()) { |
| 641 | return Status::OK(); |
| 642 | } |
| 643 | |
| 644 | #ifdef _WIN32 |
| 645 | if (!CopyFileW(sfn.ToNative().c_str(), dfn.ToNative().c_str(), |
| 646 | FALSE /* bFailIfExists */)) { |
| 647 | return IOErrorFromWinError(GetLastError(), "Failed copying '", sfn.ToString(), |
| 648 | "' to '", dfn.ToString(), "'"); |
| 649 | } |
| 650 | return Status::OK(); |
| 651 | #else |
| 652 | ARROW_ASSIGN_OR_RAISE(auto is, OpenInputStream(src)); |
| 653 | ARROW_ASSIGN_OR_RAISE(auto os, OpenOutputStream(dest)); |
| 654 | RETURN_NOT_OK(internal::CopyStream(is, os, 1024 * 1024 /* chunk_size */, io_context())); |
| 655 | RETURN_NOT_OK(os->Close()); |
| 656 | return is->Close(); |
| 657 | #endif |
| 658 | } |
| 659 | |
| 660 | namespace { |
| 661 |
nothing calls this directly
no test coverage detected