python boost 判断文件和文件夹是否存在

来源:互联网 发布:工作提醒软件 编辑:程序博客网 时间:2024/04/30 07:50

python:

         

import osif(os.path.exists("/home/zsss/project"))://file or folder    print  "exist"else:    print  "do not exist" 

c++(boost):

      

#include <iostream>#include <boost/filesystem.hpp>#include <fstream>#include <string>using namespace std;using namespace boost::filesystem;int main(){   fstream fin,fout;   fin.open("/home/zho/search/zhoucy/visual_data/visualdoc_batch_input",ios::in);   fout.open("/home/zho/search/zhoucy/visual_data/visualdoc_batch_input_tested_exist",ios::out);   string path;   while(!fin.eof())   {      fin>>path;      if(boost::filesystem::exists(path)&&boost::filesystem::exists(path+".hesaff")&&boost::filesystem::exists(path+".sift"))      {         fout<<path<<endl;       }      else       {         cout<<"the file is not all existed"<<path<<endl;        }    }    cout<<"work done"<<endl;    return 0;   } 


原创粉丝点击