-
Notifications
You must be signed in to change notification settings - Fork 17
/
move.js
45 lines (43 loc) · 998 Bytes
/
move.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* 文件复制移动逻辑
*/
function Move(dir, name) {
const fs = new FS("dsl");
var base_dir = ".trash";
// 判断文件夹是否存在.不存在就创建
Mkdir(base_dir);
var new_dir = parseInt(Date.now() / 1000);
// models的文件移动到
var target_name = dir + "/" + name;
// 如果表已经存在,则
if (Exists(dir, name)) {
Mkdir(base_dir + "/" + new_dir);
Copy(target_name, base_dir + "/" + new_dir, name);
// 复制完成后,删除文件
fs.Remove(target_name);
} else {
return false;
}
}
function Mkdir(name) {
const fs = new FS("dsl");
var res = fs.Exists(name);
if (res !== true) {
fs.Mkdir(name);
}
}
function Copy(from, to, name) {
const fs = new FS("dsl");
fs.Copy(from, to + "/" + name);
}
/**
* 查看模型是否存在
* @param {*} file_name
* @returns
*/
function Exists(dir, file_name) {
const fs = new FS("dsl");
file_name = file_name;
var res = fs.Exists(dir + "/" + file_name);
return res;
}