20 #include "recursivecopy.h" 34 extern "C" int copyFile(
const char*,
const struct stat,
int);
49 int copyFile(
const char* srcPath,
const struct stat* sb,
int typeflag)
52 std::string src(srcPath);
54 if (src.find(srcRoot) != std::string::npos) {
55 dstPath = buildPath(dstRoot, src.erase(0, srcRoot.length()));
57 dstPath = buildPath(dstRoot, src);
62 mkdir(dstPath.c_str(), sb->st_mode);
65 std::ifstream src(srcPath, std::ios::binary);
66 std::ofstream dst(dstPath, std::ios::binary);
84 if (ftw(src.c_str(), copyFile, 20) != 0) {
85 log_error() <<
"Failed to recursively copy " << src <<
" to " << dst;
93 RecursiveCopy::RecursiveCopy() {}
94 RecursiveCopy::~RecursiveCopy() {}
The RecursiveCopy class is a singleton class used to copy files recursively from a source to a destin...
static RecursiveCopy & getInstance()
getInstance Gets the RecursiveCopy instance.
bool copy(std::string src, std::string dst)
copy Copy files from src to dst
Developers guide to adding a config item: