Unix编程-列出目录下文件列表
代码
DIR *dp;
std::string dir = dataDir;
if(dir.length() > 0 && dir[dir.length() - 1] != '/')
{
dir.push_back('/');
}
if(dp = opendir(dataDir.c_str()))
{
struct dirent *dirp;
while(dirp = readdir(dp))
{
std::cout << dirp->d_name;
}
}