#include <iostream>
#include <string>
#include <regex>
#include <dirent.h>
using namespace std;
int DirProcess(string dirPath)
{
DIR *pDir;
struct dirent *pDirent;
pDir = opendir(dirPath.c_str());
if (pDir == NULL)
{
cout << dirPath << " is not existed" << endl;
return -1;
}
while ((pDirent = readdir(pDir)) != NULL)
{
string s(pDirent->d_name);
bool res = regex_match(s, regex("..xml"));
if(res)
{
std::cout<<s<<std::endl;
}
}
closedir(pDir);
return 0;
}
int main()
{
DirProcess("./data");
}
当前data目录下的文件:

运行结果:

最后
以上就是糊涂秀发最近收集整理的关于linux c++ 查找指定路径下的特定类型文件的全部内容,更多相关linux内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复