MCPcopy Create free account
hub / github.com/bytedance/bolt / copyFiles

Method copyFiles

bolt/tool/trace/TraceFileToolRunner.cpp:91–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 BOLT_UNSUPPORTED(
90 "Unsupported trace file operation type {}",
91 FLAGS_bolt_trace_file_operation);
92 }
93}
94
95void TraceFileToolRunner::copyFiles() const {
96 const auto prefixLen = sourceFs_->extractPath(sourceRootDir_).length();
97 for (const auto& source : sourceFiles_) {
98 const auto targetFile =
99 fmt::format("{}/{}", destRootDir_, source.substr(prefixLen));
100 const auto readFile = sourceFs_->openFileForRead(source);
101 const auto writeFile = destFs_->openFileForWrite(
102 targetFile,
103 filesystems::FileOptions{
104 .values = {}, .shouldCreateParentDirectories = true});
105 const auto fileSize = readFile->size();
106 constexpr auto batchSize = 4 << 10;
107 const auto ioBuf = folly::IOBuf::create(batchSize);
108 uint64_t offset = 0;
109 while (offset < fileSize) {
110 const auto curLen = std::min<uint64_t>(fileSize - offset, batchSize);
111 const auto dataView =
112 readFile->pread(offset, curLen, ioBuf->writableData());
113 writeFile->append(dataView);
114 ioBuf->append(curLen);
115 offset += curLen;
116 ioBuf->clear();
117 }
118 writeFile->flush();
119 writeFile->close();
120 }

Callers

nothing calls this directly

Calls 11

lengthMethod · 0.80
createFunction · 0.50
extractPathMethod · 0.45
openFileForReadMethod · 0.45
openFileForWriteMethod · 0.45
sizeMethod · 0.45
preadMethod · 0.45
appendMethod · 0.45
clearMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected