void getFiles(const string& rootPath,vector<string> &ret,vector<string> &name){
namespace fs = boost::filesystem;
fs::path fullpath (rootPath);
fs::recursive_directory_iterator end_iter;
for(fs::recursive_directory_iterator iter(fullpath);iter!=end_iter;iter++){
try{
if (fs::is_directory( *iter ) ){
std::cout<<*iter << "is dir" << std::endl;
ret.push_back(iter->path().string());
//ScanAllFiles::scanFiles(iter->path().string(),ret);
}else{
string file = iter->path().string();
ret.push_back(iter->path().string());
fs::path filePath(file);
//cout<<filePath.stem()<<endl;
name.push_back(filePath.stem().string());
//std::cout << *iter << " is a file" << std::endl;
}
}
boost 遍历文件夹,返回文件路径,文件名
最新推荐文章于 2025-06-20 09:47:39 发布