MCPcopy Create free account
hub / github.com/Tencent/phxqueue / RecursiveCopyDir

Function RecursiveCopyDir

phxqueue/comm/utils/file_util.cpp:302–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302int RecursiveCopyDir(const string &src_dir_path, const string &dst_dir_path, const bool recursive, const bool copy_root) {
303 int ret{-1};
304
305 if (copy_root) {
306 ret = CopyDir(move(src_dir_path), move(dst_dir_path));
307
308 if (0 != ret)
309 return ret;
310 }
311
312 ret = DoTravelDir(src_dir_path, "", dst_dir_path, nullptr, nullptr, recursive,
313 // file before
314 {},
315 // file after
316 [](const string &root_src_dir_path, const string &relative_file_path,
317 const string &root_dst_dir_path) -> int {
318 const string absolute_src_file_path{root_src_dir_path + "/" + relative_file_path};
319 const string absolute_dst_file_path{root_dst_dir_path + "/" + relative_file_path};
320
321 return CopyFile(move(absolute_src_file_path), move(absolute_dst_file_path));
322 },
323 // sub dir before
324 [](const string &root_src_dir_path, const string &relative_sub_dir_path,
325 const string &root_dst_dir_path) -> int {
326 const string absolute_src_sub_dir_path{root_src_dir_path + "/" + relative_sub_dir_path};
327 const string absolute_dst_sub_dir_path{root_dst_dir_path + "/" + relative_sub_dir_path};
328
329 return CopyDir(move(absolute_src_sub_dir_path), move(absolute_dst_sub_dir_path));
330 },
331 // sub dir after
332 {});
333
334 if (0 != ret) {
335 // TODO:
336 //QLErr("DoTravelDir \"%s\" -> \"%s\" err %d",
337 // src_dir_path.c_str(), dst_dir_path.c_str(), ret);
338
339 return ret;
340 }
341
342 return 0;
343}
344
345// deprecated functions
346

Callers 1

LoadCheckpointStateMethod · 0.85

Calls 3

CopyDirFunction · 0.85
DoTravelDirFunction · 0.85
CopyFileFunction · 0.85

Tested by

no test coverage detected