cocos2d-x3.2下获取文件夹下所有文件名的方法
2014-07-01 14:34
288 查看
这里提供一个函数获取文件夹下所有文件名的方法,直接上代码了。
原文地址:/article/1640629.html
[cpp]
view plaincopyprint?
//
// VisibleRect.cpp
// Test890
//
// Created by 杜甲 on 14-4-28.
//
//
std::vector<std::string> VisibleRect::getFilePathAtVec(std::string filePath)
{
std::vector<std::string> path_vec;
const char* path = filePath.c_str();
char *dir = (char*)malloc(filePath.size() + 1);
sprintf(dir, path);
DIR *dp;
struct dirent *entry;
struct stat statbuf;
int i=0;
if((dp=opendir(dir))==NULL)
{
fprintf(stderr,"cannot open %s",dir);
exit(1);
}
chdir(dir);
while((entry=readdir(dp))!=NULL&&i<255)
{
stat(entry->d_name,&statbuf);
if(!S_ISREG(statbuf.st_mode))
continue;
path_vec.push_back(StringUtils::format("%s",entry->d_name));
}
return path_vec;
}
原文地址:/article/1640629.html
[cpp]
view plaincopyprint?
//
// VisibleRect.cpp
// Test890
//
// Created by 杜甲 on 14-4-28.
//
//
std::vector<std::string> VisibleRect::getFilePathAtVec(std::string filePath)
{
std::vector<std::string> path_vec;
const char* path = filePath.c_str();
char *dir = (char*)malloc(filePath.size() + 1);
sprintf(dir, path);
DIR *dp;
struct dirent *entry;
struct stat statbuf;
int i=0;
if((dp=opendir(dir))==NULL)
{
fprintf(stderr,"cannot open %s",dir);
exit(1);
}
chdir(dir);
while((entry=readdir(dp))!=NULL&&i<255)
{
stat(entry->d_name,&statbuf);
if(!S_ISREG(statbuf.st_mode))
continue;
path_vec.push_back(StringUtils::format("%s",entry->d_name));
}
return path_vec;
}
相关文章推荐
- cocos2d-x3.2下获取文件夹下所有文件名的方法
- cocos2d-x3.2下获取文件夹下所有文件名的方法
- windows获取文件夹下所有文件名的方法
- Java-读取某个目录下所有文件、文件夹和3种从文件路径中获取文件名的方法
- C++ 获取文件夹下的所有文件名(此方法只只用于win)
- java获取指定文件夹下的所有文件名
- java 获取文件夹所有文件,大小,文件名
- java中获取指定文件夹下所有文件名
- C#获取文件夹下所有文件名
- 黑马程序员——list()返回该目录下文件,文件夹,listFiles()返回文件文,件夹对象,递归调用获取所有文件,文件夹,以及文件名过滤
- 如何用C#获取指定文件夹下所有文件名?
- fso获取文件夹内所有文件名列表的代码
- C#获取文件夹中所有文件的文件名
- 获取文件夹下的所有文件名,并修改某些文件名
- C++获取文件夹下的所有文件名
- windows下获取文件夹下所有文件名,并保存到文件中
- C#获取文件夹下的所有文件的文件名
- C#获取文件夹中所有文件的文件名
- DELPHI--获取某目录下的所有文件名的方法
- C++获取一个文件夹下的所有文件名