Cocos2d-x 文件系统学习笔记 分类: cocos2d代码编写 ...

文件系统访问


尽管你可以使用stdio.h头文件中的函数来访问文件,但这种方式是不太方便的,原因是:你需要激活系统特定的API接口来获取文件的完整地址。在安卓系统上安装之后,资源都被打包成了.apk文件。*希望能够基于分辨率自动加载资源(如一张图片)。


创建FileUtils类正是为解决这些问题。FileUtils是在Resources下访问文件的一个辅助类。它可以文件中读取数据和检查文件是否存在。


读取文件内容的函数


这些函数会读取不同类别的文件并返回不同的数据类型:


| function name | return type | support path type |


| getStringFromFile | std::string | relative path and absolute path |


| getDataFromFile | cocos2d::Data | relative path and absolute path |


| getFileDataFromZip | unsigned char* | absolute path |


| getValueMapFromFile | cocos2d::ValueMap | relative path and absolute path |


| getValueVectorFromFile | cocos2d::ValueVector | relative path and absolute path |


管理文件及目录的函数


这些函数能够管理文件或者目录:


| function name | support path type |


| isFileExist | relative path and absolute path |


| isDirectoryExist | relative path and absolute path |


| createDirectory | absolute path |


| removeDirectory | absolute path |


| removeFile | absolute path |


| renameFile | absolute path |


| getFileSize | relative path and absolute path |

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/leansmall/p/4715689.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值