void findfile2(const char datapath[],const string &last,vector<string> &res)
{
DIR* dir = opendir(datapath);
dirent* p = NULL;
while((p = readdir(dir)) != NULL)
{
if(p->d_name[0] == '.')
continue;
string filename = string(p->d_name);
// cout<<filename<<endl;
string lab = "bmp";
if(filename.rfind(last) != -1)
{
string name = datapath + string(p->d_name);
res.push_back(name);
}
}
if(res.size() == 0)
cout<<"no file found !";
}
datapath : 要遍历的目录
last : 指定要查找文件的格式名
res : 所有路径的vector