1# RawFile(资源管理) 2 3### 介绍 4 5本工程主要实现了[Rawfile开发指导](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/rawfile-guidelines.md)中功能,开发者可以通过本项目了解如何使用Native Rawfile接口操作Rawfile目录和文件。功能包括文件列表遍历、文件打开、搜索、读取和关闭Rawfile。 6 7### 效果预览 8 9| 显示页面 | 点击后日志打印效果 | 10| ------------------------------------------------------------ | ----------------------------------------------- | 11|  |  | 12 13### 使用说明 14 151. 启动项目后,会显示带有“Hello World”的文本页面; 162. 点击“Hello World”文本触发点击事件; 173. 关注DevEco中的日志窗口,会打印log显示处理结果,包括文件资源的文件列表、文件、文件描述符; 18 19### 目录结构 20 21``` 22RawFile/entry/src/ 23|---main 24│ |---cpp 25│ │ |---CMakeLists.txt(CMake构建配置文件) 26│ │ |---hello.cpp(RawFile的主要功能逻辑文件) 27│ │ |---types 28│ │ |---libentry 29│ │ |---Index.d.ts(应用侧函数声明文件) 30│ │ |---oh-package.json5 31│ |---ets 32│ │ |---pages 33│ │ |---Index.ets(构建页面,调用RawFile功能函数输出Log日志) 34│ |---resources 35│ |---rawfile(RawFile调用的资源文件) 36│ │ |---rawfile.txt 37│ │ |---rawfile1.txt 38│ │ |---subrawfile 39│ │ |---rawfile2.txt 40``` 41 42### 具体实现 43 44- 想要使用Native Rawfile接口操作Rawfile目录和文件。功能包括文件列表遍历、文件打开、搜索、读取和关闭Rawfile,需要在CPP目录下的index.d.ts文件中声明应用侧函数getFileList()、getRawFileContent()、getRawFileDescriptor()。 45- 在hallo.cpp中实现getFileList()、getRawFileContent()、getRawFileDescriptor()的具体代码,实际操作逻辑。 46- 在ets目录下的index.ets文件就可以通过import testNapi from "libentry.so";导入相关库,进行对上述函数的调用。 47 48### 相关权限 49 50不涉及。 51 52### 依赖 53 54不涉及。 55 56### 约束与限制 57 581. 本示例仅支持标准系统上运行,支持设备:RK3568; 592. 本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.58; 603. 本示例需要使用DevEco Studio Beta1(5.0.5.200)及以上版本才可编译运行; 61 62### 下载 63 64如需单独下载本工程,执行如下命令: 65 66``` 67git init 68git config core.sparsecheckout true 69echo code/DocsSample/ResourceManagement/RawFile/ > .git/info/sparse-checkout 70git remote add origin https://gitee.com/openharmony/applications_app_samples.git 71git pull origin main 72```