当前位置:网站首页>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
}
边栏推荐
- The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
- For penetration testing methods where the output point is a timestamp (take Oracle database as an example)
- Principle analysis of famous website msdn.itellyou.cn
- Chinese garbled solution in UTF-8 environment in Powershell
- cocos2d-x-3.2 image graying effect
- SQLite 查询表中每天插入的数量
- 浅谈对分布式模式下CAP的理解
- TransactionTemplate 事务编程式写法
- DC-CDN学习笔记
- [swagger close] The production environment closes the swagger method
猜你喜欢
js中的this指向与原型对象
场效应管 | N-mos内部结构详解
JS写一段代码,判断一个字符串中出现次数最多的字符串,并统计出现的次数JS
For penetration testing methods where the output point is a timestamp (take Oracle database as an example)
jenkins +miniprogram-ci upload WeChat applet with one click
Nmap的下载与安装
Notes on creating a new virtual machine in Hyper-V
如何修改数据库密码
VS connects to MYSQL through ODBC (2)
Global scope and function scope in js
随机推荐
RuntimeError: CUDA error: no kernel image is available for execution on the device问题记录
VS2017连接MYSQL
安装Multisim出现 No software will be installed or removed解决方法
break and continue exit in js
Several forms of Attribute Changer
浏览器查找js绑定或者监听的事件
VS connects to MYSQL through ODBC (1)
Podspec automatic upgrade script
WeChat applet source code acquisition and decompilation method
[windows]--- SQL Server 2008 super detailed installation tutorial
quick lua加密
sqlmap injection tutorial common commands
Using IIS10 to build an asp website in win11
Filter out egrep itself when using ps | egrep
What is the difference between NFT and digital collection?
禅道安装及使用教程
understand js operators
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
活体检测PatchNet学习笔记
np.fliplr与np.flipud