MCPcopy Create free account
hub / github.com/apache/arrow / CopyFile

Method CopyFile

cpp/src/arrow/filesystem/localfs.cc:634–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634Status 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
660namespace {
661

Callers

nothing calls this directly

Calls 7

IOErrorFromWinErrorFunction · 0.85
CopyStreamFunction · 0.85
io_contextFunction · 0.85
ValidatePathFunction · 0.70
OKFunction · 0.50
ToStringMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected