int readFileList(const std::string &folderPath,
std::vector<std::string> &vFileList)
{
DIR *dp;
struct dirent *dirp;
if ((dp = opendir(folderPath.c_str())) == NULL)
{
return 0;
}
int num = 0;
while ((dirp = readdir(dp)) != NULL)
{
std::string name = std::string(dirp->d_name);
if (name != "." && name != "..")
{
vFileList.push_back(name);
num++;
}
}
closedir(dp);
// std::sort(vFileList.begin(), vFileList.end());
return num;
}
c++读取文件夹下所有文件名
最新推荐文章于 2023-10-27 21:33:22 发布