添加移除文件接口

This commit is contained in:
2020-07-24 14:19:19 +08:00
parent c7f9bfbd61
commit 08e4de1524

View File

@@ -81,6 +81,15 @@ export class DirAccess {
} }
} }
static remove_file_or_error(path: string) {
switch (get_runtime()) {
case JavaScriptRuntime.NodeJS:
return NodeJSDirAccess.remove_file_or_error(path);
default:
return false;
}
}
static make_dir(p_dir: string, recursive: boolean = false) { static make_dir(p_dir: string, recursive: boolean = false) {
switch (get_runtime()) { switch (get_runtime()) {
case JavaScriptRuntime.NodeJS: case JavaScriptRuntime.NodeJS:
@@ -166,4 +175,8 @@ export class NodeJSDirAccess extends DirAccess {
static make_dir(p_dir: string, recursive: boolean = false) { static make_dir(p_dir: string, recursive: boolean = false) {
fs.mkdirSync(p_dir, {recursive: true}); fs.mkdirSync(p_dir, {recursive: true});
} }
static remove_file_or_error(path: string) {
fs.unlinkSync(path);
}
} }