#include<iostream>
#include <filesystem>
void cloneFiles(std::string raw_path, std::string new_path){
if (!exists(new_path)){
if (create_directory(new_path)) {
std::cout << "successfully created directories:" << new_path << std::endl;
}
else{
std::cout << "failed to create directories:" << new_path << std::endl;
return;
}
}
for (auto &v : boost::filesystem::directory_iterator(raw_path)){
std::string fileName = v.path().filename().string();
std::string raw_file = raw_path + "/" + fileName;
std::string new_file = new_path + "/" +fileName;
std::ifstream src(raw_file, std::ios::binary);
std::ofstream dst(new_file, std::ios::binary);
st << src.rdbuf();
}
}
C++将一个路径下的所有文件完全拷贝到另外一个路径下
最新推荐文章于 2024-05-03 00:00:16 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)