当前位置:网站首页>cocos2d-x implements cross-platform directory traversal
cocos2d-x implements cross-platform directory traversal
2022-07-31 06:03:00 【xuyid】
#include
#else
#include
#include
#include
#include
#endif
void dfsFolder(string folderPath,int depth = 0);
void dfsFolder( string folderPath, int depth)
{
#ifdef WIN32
_finddata_t FileInfo;
string strfind = folderPath + "\\*";
long Handle = _findfirst(strfind.c_str(), &FileInfo);
if (Handle == -1L)
{
cerr << "can not match the folder path" << endl;
exit(-1);
}
do{
// Determine if there are subdirectories
if (FileInfo.attrib & _A_SUBDIR)
{
//This statement is very important
If((strcmp(FileInfo.name,".") != 0 ) &&(strcmp(FileInfo.name,"..") != 0))
{
string newPath = folderPath + "\\" + FileInfo.name;
dfsFolder(newPath);
}
, }
else
string filename = (folderPath + "\\" + FileInfo.name);
28 cout << folderPath << "\\" << FileInfo.name << " " << endl;
_findclose(Handle);
#else
DIR *dp;
struct dirent *entry;
struct stat statbuf;
if((dp = opendir(folderPath.c_str())) == NULL) {
fprintf(stderr,"cannot open directory: %s\n", folderPath.c_str());
return;
}
chdir(folderPath.c_str());
while((entry = readdir(dp)) != NULL) {
lstat(entry->d_name,&statbuf);
if(S_ISDIR(statbuf.st_mode)) {
if(strcmp(".",entry->d_name) == 0 ||
strcmp("..",entry->d_name) == 0)
continue;
printf("%*s%s/\n",depth,"",entry->d_name);
dfsFolder(entry->d_name,depth+4);
} else {
string filename=entry->d_name;
54 printf("%*s%s\n",depth,"",entry->d_name);
54 }
}
chdir("..");
closedir(dp);
#endif
}
边栏推荐
猜你喜欢

np.fliplr与np.flipud

For penetration testing methods where the output point is a timestamp (take Oracle database as an example)

js中的全局作用域与函数作用域

Android软件安全与逆向分析阅读笔记

Understanding of js arrays

著名网站msdn.itellyou.cn原理分析

Common JVM interview questions and answers

Multi-Modal Face Anti-Spoofing Based on Central Difference Networks学习笔记

Nmap的下载与安装

VS2017连接MYSQL
随机推荐
自定dialog 布局没有居中解决方案
cv2.imread()
多元线性回归方程原理及其推导
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
After unicloud is released, the applet prompts that the connection to the local debugging service failed. Please check whether the client and the host are under the same local area network.
The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
MySQL面试题大全(陆续更新)
this指向问题
WeChat applet source code acquisition and decompilation method
cocoscreator 显示刘海内容
[windows]--- SQL Server 2008 super detailed installation tutorial
Podspec verification dependency error problem pod lib lint , need to specify the source
Several forms of Attribute Changer
VS2017连接MYSQL
js中的函数
一文速学-玩转MySQL获取时间、格式转换各类操作方法详解
js中流程控制语句
[Cloud native] Open source data analysis SPL easily copes with T+0
quick-3.5 ActionTimeline的setLastFrameCallFunc调用会崩溃问题
MySql to create data tables