Assets相关
typescript
import core from 'cheese-core';
const assets = core.assets;
读取文件或文件夹: read(path: string): string
✅
参数:
- ⭐
string
(path): 路径
返回值:
- 🟢
string
: 文件内容 or 文件列表 - 🔴null
用法示例:
typescript
const fileContent = assets.read("ww/test.txt");
console.log("文件内容",fileContent);
拷贝文件或文件夹: copy(path: string, destPath: string): boolean
✅
参数:
- ⭐
string
(path): 文件或文件夹路径 - ⭐
string
(destPath): 目标路径
返回值:
- 🟢
boolean
: true - 🔴
boolean
: false
用法示例:
typescript
if(assets.copy("ww/test.txt","/storage/emulated/0/t.txt")){
console.log("复制成功");
}
判断路径是不是文件夹: isFolder(path: string): boolean
✅
参数:
- ⭐
string
(path): 路径
返回值:
- 🟢
boolean
: true - 🔴
boolean
: false
用法示例:
typescript
if(assets.isFolder("ww")){
console.log("是文件夹");
}
判断路径是不是文件: isFile(path: string): boolean
✅
参数:
- ⭐
string
(path): 路径
返回值:
- 🟢
boolean
: true - 🔴
boolean
: false
用法示例:
typescript
if(assets.isFile("ww/test.txt")){
console.log("是文件");
}