- API 概览
- 开放能力
- 基础
- 渲染
- 设备
- 文件
- 位置
- 媒体
- 网络
- 游戏转发分享
- 实时语音
- 数据缓存
- 系统
- 广告
- 界面
- 支付
- Worker
FileSystemManager.rmdirSync收藏我的收藏
收藏
我的收藏基础库 1.15.0 开始支持本方法,这是一个同步方法。
删除目录,开发者只能删除 用户目录(ttfile://user) 下的目录。
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 无 |
注意事项 | 开发者只能删除 ttfile://user 下的目录 |
相关教程 | 无 |
语法
FileSystemManager.rmdirSync(dirPath, recursive)
参数说明
dirPath
类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|
string | 是 | 要删除的目录路径, 必须以 ttfile://user 开头的字符串 | 1.15.0 |
recursive
类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|
boolean | 否 | 是否递归删除目录下的文件 | 1.15.0 |
返回值
无
错误码
errNo | errMsg | 说明 | 最低支持版本 |
---|---|---|---|
20000 | rmdirSync:fail dirPath is invalid | dirPath 参数错误 | 1.99.0 |
20001 | rmdirSync:fail param should be xxx, but got xxx | 参数校验错误 | 1.99.0 |
21101 | rmdirSync:fail permission denied, rmdirSync {dirPath_value} | dirPath 路径不可写 | 1.99.0 |
21102 | rmdirSync:fail no such file or directory, rmdirSync {dirPath_value} | dirPath 路径不存在 | 1.99.0 |
21103 | rmdirSync:fail directory not empty | 目录不为空,且 recursive 为 false | 1.99.0 |
21105 | rmdirSync:fail operation not permitted, rmdirSync {dirPath_value} | 类型不正确(不是目录) | 1.99.0 |
代码示例
const fileSystemManager = tt.getFileSystemManager();
// 必须以 "ttfile://user" 开头
const exmaplePath = "ttfile://user/example-dir";
try {
fileSystemManager.mkdirSync(exmaplePath);
console.log("成功");
} catch (err) {
console.log("失败", err);
}
try {
fileSystemManager.rmdirSync(exmaplePath);
console.log("成功");
} catch (err) {
console.log("失败", err);
}
该文档是否有帮助?
点击纠错