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

Function RecursiveRemoveDir

phxqueue/comm/utils/file_util.cpp:267–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267int RecursiveRemoveDir(const string &dir_path, const bool recursive, const bool remove_root) {
268 int ret{-1};
269
270 ret = DoTravelDir(dir_path, "", "", nullptr, nullptr, recursive,
271 // file before
272 [](const string &root_dir_path, const string &relative_file_path, const string &) -> int {
273 const string absolute_file_path{root_dir_path + "/" + relative_file_path};
274
275 return RemoveFile(move(absolute_file_path));
276 },
277 // file after
278 {},
279 // sub dir before
280 {},
281 // sub dir after
282 [](const string &root_dir_path, const string &relative_sub_dir_path, const string &) -> int {
283 const string absolute_sub_dir_path{root_dir_path + "/" + relative_sub_dir_path};
284
285 return RemoveDir(move(absolute_sub_dir_path));
286 });
287
288 if (0 != ret) {
289 // TODO:
290 //QLErr("DoTravelDir \"%s\" err %d", dir_path.c_str(), ret);
291
292 return ret;
293 }
294
295 if (remove_root) {
296 return RemoveDir(move(dir_path));
297 }
298
299 return 0;
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};

Callers 1

LoadCheckpointStateMethod · 0.85

Calls 3

DoTravelDirFunction · 0.85
RemoveFileFunction · 0.85
RemoveDirFunction · 0.85

Tested by

no test coverage detected