FileSystemManager.stat
基础库 1.15.0 开始支持本方法,低版本需做兼容处理。
获取文件 Stats 对象。
语法
FileSystemManager.stat(options)
参数说明
options
options 为 object 类型,属性描述如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
path | string | 是 | 文件/目录路径 | 1.15.0 | |
success | Function | 否 | 接口调用成功的回调函数 | 1.15.0 | |
fail | Function | 否 | 接口调用失败的回调函数 | 1.15.0 | |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 1.15.0 |
回调成功
回调参数为 object 类型,属性如下:
属性 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | 1.15.0 | |
stat | Stats | Stats 对象 | 1.15.0 |
回调失败
回调参数为 object 类型,属性如下:
属性 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | "stat:fail " + 详细错误信息 | 1.15.0 |
errMsg 说明 | 说明 |
---|---|
fail permission denied, open ${path} | 指定的 path 路径没有读权限 |
fail no such file or directory ${path} | 文件不存在 |
扫码体验
请使用字节宿主APP扫码
代码示例
const fileSystemManager = tt.getFileSystemManager();
tt.chooseImage({
success(res) {
const tempFile = res.tempFilePaths[0];
fileSystemManager.stat({
path: tempFile,
success(res) {
console.log("是否是目录:", res.stat.isDirectory());
console.log("是否是文件:", res.stat.isFile());
},
fail(res) {
console.log("调用失败", res.errMsg);
},
});
},
});
Bug & Tip
无
点击纠错
评价此篇文档