当前位置:网站首页>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
}
边栏推荐
- Podspec verification dependency error problem pod lib lint , need to specify the source
- 计网 Packet Tracer仿真 | 简单易懂集线器和交换机对比(理论+仿真)
- flutter arr 依赖
- Hyper-V新建虚拟机注意事项
- ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
- Why does read in bash need to cooperate with while to read the contents of /dev/stdin
- TransactionTemplate transaction programmatic way
- configure:error no SDL library found
- MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
- Navicat从本地文件中导入sql文件
猜你喜欢

VS2017 connects to MYSQL

Powershell中UTF-8环境中文乱码解决办法
![[uiautomation] Get WeChat friend list (stored in txt)](/img/26/1f3424c5998c52c6e10ced8529012a.png)
[uiautomation] Get WeChat friend list (stored in txt)

unicloud 发布后小程序提示连接本地调试服务失败,请检查客户端是否和主机在同一局域网下

VTK:Could not locate vtkTextRenderer object.

flutter 混合开发 module 依赖

np.fliplr与np.flipud

MySql to create data tables

活体检测PatchNet学习笔记

Artifact SSMwar exploded Error deploying artifact.See server log for details
随机推荐
对js的数组的理解
C语言 | 获取字符串里逗号间隔的内容
Why does read in bash need to cooperate with while to read the contents of /dev/stdin
The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
OpenCV中的图像数据格式CV_8U定义
this points to the problem
2021美赛C题M奖思路
NFTs: The Heart of Digital Ownership
为什么bash中的read要配合while才能读取/dev/stdin的内容
Chinese garbled solution in UTF-8 environment in Powershell
一文速学-玩转MySQL获取时间、格式转换各类操作方法详解
2021年京东数据分析工程师秋招笔试编程题
使用 OpenCV 提取图像的 HOG、SURF 及 LBP 特征 (含代码)
kotlin 插件更新到1.3.21
使用ps | egrep时过滤排除掉egrep自身
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
多元线性回归方程原理及其推导
MySQL面试题大全(陆续更新)
著名网站msdn.itellyou.cn原理分析
VS通过ODBC连接MYSQL(一)