boost 遍历文件夹,返回文件路径,文件名

void getFiles(const string& rootPath,vector &ret,vector &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<

-lboost_filesystem -lboost_system

你可能感兴趣的:(C++)