clickgo 3.0.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +75 -0
- package/dist/app/demo/config.json +106 -0
- package/dist/app/demo/form/control/block/block.css +1 -0
- package/dist/app/demo/form/control/block/block.scss +17 -0
- package/dist/app/demo/form/control/block/block.xml +7 -0
- package/dist/app/demo/form/control/button/button.css +1 -0
- package/dist/app/demo/form/control/button/button.js +27 -0
- package/dist/app/demo/form/control/button/button.scss +18 -0
- package/dist/app/demo/form/control/button/button.xml +126 -0
- package/dist/app/demo/form/control/check/check.js +12 -0
- package/dist/app/demo/form/control/check/check.xml +13 -0
- package/dist/app/demo/form/control/dialog/dialog.js +8 -0
- package/dist/app/demo/form/control/dialog/dialog.xml +26 -0
- package/dist/app/demo/form/control/file/file.js +23 -0
- package/dist/app/demo/form/control/file/file.xml +25 -0
- package/dist/app/demo/form/control/form/form.css +1 -0
- package/dist/app/demo/form/control/form/form.js +38 -0
- package/dist/app/demo/form/control/form/form.scss +9 -0
- package/dist/app/demo/form/control/form/form.xml +28 -0
- package/dist/app/demo/form/control/greatview/greatview.css +1 -0
- package/dist/app/demo/form/control/greatview/greatview.js +92 -0
- package/dist/app/demo/form/control/greatview/greatview.scss +22 -0
- package/dist/app/demo/form/control/greatview/greatview.xml +89 -0
- package/dist/app/demo/form/control/img/img.xml +16 -0
- package/dist/app/demo/form/control/label/label.xml +11 -0
- package/dist/app/demo/form/control/list/list.css +1 -0
- package/dist/app/demo/form/control/list/list.js +194 -0
- package/dist/app/demo/form/control/list/list.scss +7 -0
- package/dist/app/demo/form/control/list/list.xml +91 -0
- package/dist/app/demo/form/control/loading/loading.xml +8 -0
- package/dist/app/demo/form/control/marquee/marquee.js +30 -0
- package/dist/app/demo/form/control/marquee/marquee.xml +36 -0
- package/dist/app/demo/form/control/menu/menu.js +8 -0
- package/dist/app/demo/form/control/menu/menu.xml +122 -0
- package/dist/app/demo/form/control/monaco/monaco.js +113 -0
- package/dist/app/demo/form/control/monaco/monaco.xml +27 -0
- package/dist/app/demo/form/control/overflow/overflow.css +1 -0
- package/dist/app/demo/form/control/overflow/overflow.js +70 -0
- package/dist/app/demo/form/control/overflow/overflow.scss +18 -0
- package/dist/app/demo/form/control/overflow/overflow.xml +98 -0
- package/dist/app/demo/form/control/property/property.js +129 -0
- package/dist/app/demo/form/control/property/property.xml +6 -0
- package/dist/app/demo/form/control/radio/radio.js +7 -0
- package/dist/app/demo/form/control/radio/radio.xml +12 -0
- package/dist/app/demo/form/control/scroll/scroll.js +14 -0
- package/dist/app/demo/form/control/scroll/scroll.xml +35 -0
- package/dist/app/demo/form/control/select/select.js +91 -0
- package/dist/app/demo/form/control/select/select.xml +74 -0
- package/dist/app/demo/form/control/tab/tab.js +75 -0
- package/dist/app/demo/form/control/tab/tab.xml +22 -0
- package/dist/app/demo/form/control/text/text.js +53 -0
- package/dist/app/demo/form/control/text/text.xml +37 -0
- package/dist/app/demo/form/control/view/view.css +1 -0
- package/dist/app/demo/form/control/view/view.js +73 -0
- package/dist/app/demo/form/control/view/view.scss +18 -0
- package/dist/app/demo/form/control/view/view.xml +94 -0
- package/dist/app/demo/form/event/form/form.css +1 -0
- package/dist/app/demo/form/event/form/form.js +129 -0
- package/dist/app/demo/form/event/form/form.scss +24 -0
- package/dist/app/demo/form/event/form/form.xml +16 -0
- package/dist/app/demo/form/event/screen/screen.js +51 -0
- package/dist/app/demo/form/event/screen/screen.xml +9 -0
- package/dist/app/demo/form/event/task/task.js +78 -0
- package/dist/app/demo/form/event/task/task.xml +20 -0
- package/dist/app/demo/form/main.css +1 -0
- package/dist/app/demo/form/main.js +25 -0
- package/dist/app/demo/form/main.scss +9 -0
- package/dist/app/demo/form/main.xml +49 -0
- package/dist/app/demo/form/method/core/core.js +25 -0
- package/dist/app/demo/form/method/core/core.xml +7 -0
- package/dist/app/demo/form/method/dom/dom.css +1 -0
- package/dist/app/demo/form/method/dom/dom.js +163 -0
- package/dist/app/demo/form/method/dom/dom.scss +10 -0
- package/dist/app/demo/form/method/dom/dom.xml +55 -0
- package/dist/app/demo/form/method/form/form.css +1 -0
- package/dist/app/demo/form/method/form/form.js +217 -0
- package/dist/app/demo/form/method/form/form.scss +3 -0
- package/dist/app/demo/form/method/form/form.xml +56 -0
- package/dist/app/demo/form/method/form/test.xml +5 -0
- package/dist/app/demo/form/method/fs/fs.js +88 -0
- package/dist/app/demo/form/method/fs/fs.xml +8 -0
- package/dist/app/demo/form/method/fs/text.js +15 -0
- package/dist/app/demo/form/method/fs/text.xml +3 -0
- package/dist/app/demo/form/method/task/locale1.json +3 -0
- package/dist/app/demo/form/method/task/locale2.json +3 -0
- package/dist/app/demo/form/method/task/task.js +153 -0
- package/dist/app/demo/form/method/task/task.xml +57 -0
- package/dist/app/demo/form/method/theme/theme.js +74 -0
- package/dist/app/demo/form/method/theme/theme.xml +9 -0
- package/dist/app/demo/form/method/tool/tool.js +64 -0
- package/dist/app/demo/form/method/tool/tool.xml +26 -0
- package/dist/app/demo/form/method/zip/zip.js +99 -0
- package/dist/app/demo/form/method/zip/zip.xml +12 -0
- package/dist/app/demo/global.css +3 -0
- package/dist/app/demo/res/icon.svg +1 -0
- package/dist/app/demo/res/img.jpg +0 -0
- package/dist/app/demo/res/r-1.svg +1 -0
- package/dist/app/demo/res/r-2.svg +1 -0
- package/dist/app/demo/res/sql.svg +1 -0
- package/dist/app/demo/res/txt.svg +1 -0
- package/dist/app/demo/res/zip.svg +1 -0
- package/dist/app/task/config.json +29 -0
- package/dist/app/task/form/bar/bar.js +299 -0
- package/dist/app/task/form/bar/bar.xml +47 -0
- package/dist/app/task/form/desktop/desktop.xml +1 -0
- package/dist/app/task/locale/en.json +11 -0
- package/dist/app/task/locale/ja.json +11 -0
- package/dist/app/task/locale/sc.json +11 -0
- package/dist/app/task/locale/tc.json +11 -0
- package/dist/clickgo.js +41 -0
- package/dist/clickgo.ts +51 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -0
- package/dist/icon.png +0 -0
- package/dist/index.js +88 -0
- package/dist/index.ts +92 -0
- package/dist/lib/control.js +365 -0
- package/dist/lib/control.ts +428 -0
- package/dist/lib/core.js +668 -0
- package/dist/lib/core.ts +732 -0
- package/dist/lib/dom.js +1471 -0
- package/dist/lib/dom.ts +1785 -0
- package/dist/lib/form.js +2101 -0
- package/dist/lib/form.ts +2496 -0
- package/dist/lib/fs.js +849 -0
- package/dist/lib/fs.ts +995 -0
- package/dist/lib/native.js +138 -0
- package/dist/lib/native.ts +219 -0
- package/dist/lib/task.js +686 -0
- package/dist/lib/task.ts +842 -0
- package/dist/lib/theme.js +159 -0
- package/dist/lib/theme.ts +196 -0
- package/dist/lib/tool.js +501 -0
- package/dist/lib/tool.ts +620 -0
- package/dist/lib/zip.js +352 -0
- package/dist/lib/zip.ts +434 -0
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +27 -0
- package/types/dev.d.ts +30 -0
- package/types/index.d.ts +673 -0
package/dist/lib/fs.js
ADDED
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.copyFile = exports.copyFolder = exports.readDir = exports.rename = exports.chmod = exports.rmdirDeep = exports.rmdir = exports.mkdir = exports.isFile = exports.isDir = exports.stats = exports.unlink = exports.symlink = exports.readLink = exports.putContent = exports.getContent = void 0;
|
|
13
|
+
const tool = require("./tool");
|
|
14
|
+
const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/greatview/', '/app/demo/form/control/greatview/greatview.css', '/app/demo/form/control/greatview/greatview.js', '/app/demo/form/control/greatview/greatview.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/overflow/', '/app/demo/form/control/overflow/overflow.css', '/app/demo/form/control/overflow/overflow.js', '/app/demo/form/control/overflow/overflow.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/view/', '/app/demo/form/control/view/view.css', '/app/demo/form/control/view/view.js', '/app/demo/form/control/view/view.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/form/test.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/property.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
|
|
15
|
+
function getContent(path, options) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
path = tool.urlResolve('/', path);
|
|
18
|
+
const fpath = path.slice(8);
|
|
19
|
+
if (typeof options === 'string') {
|
|
20
|
+
options = {
|
|
21
|
+
'encoding': options
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
else if (!options) {
|
|
25
|
+
options = {};
|
|
26
|
+
}
|
|
27
|
+
const encoding = options.encoding;
|
|
28
|
+
const start = options.start;
|
|
29
|
+
const end = options.end;
|
|
30
|
+
if (path.startsWith('/clickgo/') || path.startsWith('http:') || path.startsWith('https:')) {
|
|
31
|
+
let ourl = '';
|
|
32
|
+
if (path.startsWith('/clickgo/')) {
|
|
33
|
+
if (!clickgoFiles.includes(fpath)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
ourl = tool.urlResolve(__dirname, './').slice(0, -1) + fpath;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
ourl = path;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const rand = Math.random().toString();
|
|
43
|
+
let blob = null;
|
|
44
|
+
const headers = {};
|
|
45
|
+
if (start || end) {
|
|
46
|
+
headers['range'] = `bytes=${start === undefined ? '0' : start}-${end === undefined ? '' : end}`;
|
|
47
|
+
}
|
|
48
|
+
if (options.progress) {
|
|
49
|
+
blob = yield tool.request(ourl + '?' + rand, {
|
|
50
|
+
'headers': headers,
|
|
51
|
+
'progress': options.progress,
|
|
52
|
+
'responseType': 'blob'
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
blob = yield (yield fetch(ourl + '?' + rand, {
|
|
57
|
+
'headers': headers
|
|
58
|
+
})).blob();
|
|
59
|
+
}
|
|
60
|
+
if (!blob) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (!encoding) {
|
|
64
|
+
return blob;
|
|
65
|
+
}
|
|
66
|
+
return yield new Promise(function (resolve) {
|
|
67
|
+
const fr = new FileReader();
|
|
68
|
+
fr.addEventListener('load', function () {
|
|
69
|
+
resolve(fr.result);
|
|
70
|
+
});
|
|
71
|
+
fr.readAsText(blob, encoding);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (_a) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (path.startsWith('/storage/')) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
else if (path.startsWith('/mounted/')) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
else if (path.startsWith('/package/')) {
|
|
85
|
+
if (!options.files) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const file = options.files[fpath];
|
|
89
|
+
if (!file) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (typeof file === 'string') {
|
|
93
|
+
return file;
|
|
94
|
+
}
|
|
95
|
+
if (!options.encoding) {
|
|
96
|
+
return file;
|
|
97
|
+
}
|
|
98
|
+
const encoding = options.encoding;
|
|
99
|
+
return new Promise(function (resolve) {
|
|
100
|
+
const fr = new FileReader();
|
|
101
|
+
fr.addEventListener('load', function () {
|
|
102
|
+
resolve(fr.result);
|
|
103
|
+
});
|
|
104
|
+
fr.readAsText(file, encoding);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else if (path.startsWith('/current/')) {
|
|
108
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
options.current = options.current.slice(0, -1);
|
|
112
|
+
return getContent(options.current + fpath, options);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.getContent = getContent;
|
|
120
|
+
function putContent(path, data, options = {}) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
path = tool.urlResolve('/', path);
|
|
123
|
+
const fpath = path.slice(8);
|
|
124
|
+
if (path.startsWith('/clickgo/')) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
else if (path.startsWith('/storage/')) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
else if (path.startsWith('/mounted/')) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
else if (path.startsWith('/package/')) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
else if (path.startsWith('/current/')) {
|
|
137
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
options.current = options.current.slice(0, -1);
|
|
141
|
+
return putContent(options.current + fpath, data, options);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
exports.putContent = putContent;
|
|
149
|
+
function readLink(path, options) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
path = tool.urlResolve('/', path);
|
|
152
|
+
const fpath = path.slice(8);
|
|
153
|
+
if (typeof options === 'string') {
|
|
154
|
+
options = {
|
|
155
|
+
'encoding': options
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else if (!options) {
|
|
159
|
+
options = {};
|
|
160
|
+
}
|
|
161
|
+
if (path.startsWith('/clickgo/')) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
else if (path.startsWith('/storage/')) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
else if (path.startsWith('/mounted/')) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
else if (path.startsWith('/package/')) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
else if (path.startsWith('/current/')) {
|
|
174
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return options.current;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
exports.readLink = readLink;
|
|
185
|
+
function symlink(filePath, linkPath, options = {}) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
filePath = tool.urlResolve('/', filePath);
|
|
188
|
+
linkPath = tool.urlResolve('/', linkPath);
|
|
189
|
+
if (filePath.startsWith('/clickgo/')) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
else if (filePath.startsWith('/storage/')) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
else if (filePath.startsWith('/mounted/')) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
else if (filePath.startsWith('/package/')) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
else if (filePath.startsWith('/current/')) {
|
|
202
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
options.current = options.current.slice(0, -1);
|
|
206
|
+
if (linkPath.startsWith('/current/')) {
|
|
207
|
+
linkPath = options.current + linkPath.slice(8);
|
|
208
|
+
}
|
|
209
|
+
return symlink(options.current + filePath.slice(8), linkPath, options);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
exports.symlink = symlink;
|
|
217
|
+
function unlink(path, options = {}) {
|
|
218
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
path = tool.urlResolve('/', path);
|
|
220
|
+
const fpath = path.slice(8);
|
|
221
|
+
if (path.startsWith('/clickgo/')) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
else if (path.startsWith('/storage/')) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
else if (path.startsWith('/mounted/')) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
else if (path.startsWith('/package/')) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
else if (path.startsWith('/current/')) {
|
|
234
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
options.current = options.current.slice(0, -1);
|
|
238
|
+
return unlink(options.current + fpath, options);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
exports.unlink = unlink;
|
|
246
|
+
function getClickGoStats(path) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
if (path.endsWith('/')) {
|
|
249
|
+
const date = new Date();
|
|
250
|
+
const ms = date.getTime();
|
|
251
|
+
return {
|
|
252
|
+
isFile: function () {
|
|
253
|
+
return false;
|
|
254
|
+
},
|
|
255
|
+
isDirectory: function () {
|
|
256
|
+
return true;
|
|
257
|
+
},
|
|
258
|
+
isSymbolicLink: function () {
|
|
259
|
+
return false;
|
|
260
|
+
},
|
|
261
|
+
'size': 0,
|
|
262
|
+
'blksize': 0,
|
|
263
|
+
'atimeMs': ms,
|
|
264
|
+
'mtimeMs': ms,
|
|
265
|
+
'ctimeMs': ms,
|
|
266
|
+
'birthtimeMs': ms,
|
|
267
|
+
'atime': date,
|
|
268
|
+
'mtime': date,
|
|
269
|
+
'ctime': date,
|
|
270
|
+
'birthtime': date
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
try {
|
|
275
|
+
const res = yield fetch(tool.urlResolve(__dirname, './').slice(0, -1) + path + '?' + Math.random().toString(), {
|
|
276
|
+
'headers': {
|
|
277
|
+
'range': `bytes=0-1`
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
const hdate = res.headers.get('date');
|
|
281
|
+
const hmdate = res.headers.get('last-modified');
|
|
282
|
+
const hlength = res.headers.get('content-length');
|
|
283
|
+
let date = new Date();
|
|
284
|
+
let mdate = date;
|
|
285
|
+
if (hdate) {
|
|
286
|
+
date = new Date(hdate);
|
|
287
|
+
}
|
|
288
|
+
if (hmdate) {
|
|
289
|
+
mdate = new Date(hmdate);
|
|
290
|
+
}
|
|
291
|
+
const ms = date.getTime();
|
|
292
|
+
const mms = mdate.getTime();
|
|
293
|
+
return {
|
|
294
|
+
isFile: function () {
|
|
295
|
+
return true;
|
|
296
|
+
},
|
|
297
|
+
isDirectory: function () {
|
|
298
|
+
return false;
|
|
299
|
+
},
|
|
300
|
+
isSymbolicLink: function () {
|
|
301
|
+
return false;
|
|
302
|
+
},
|
|
303
|
+
'size': hlength ? parseInt(hlength) : 0,
|
|
304
|
+
'blksize': hlength ? parseInt(hlength) : 0,
|
|
305
|
+
'atimeMs': ms,
|
|
306
|
+
'mtimeMs': mms,
|
|
307
|
+
'ctimeMs': mms,
|
|
308
|
+
'birthtimeMs': ms,
|
|
309
|
+
'atime': date,
|
|
310
|
+
'mtime': mdate,
|
|
311
|
+
'ctime': mdate,
|
|
312
|
+
'birthtime': date
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
catch (_a) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function stats(path, options = {}) {
|
|
322
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
323
|
+
path = tool.urlResolve('/', path);
|
|
324
|
+
let fpath = path.slice(8);
|
|
325
|
+
if (path.startsWith('/clickgo/')) {
|
|
326
|
+
if (!clickgoFiles.includes(fpath)) {
|
|
327
|
+
if (!clickgoFiles.includes(fpath + '/')) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
fpath += '/';
|
|
331
|
+
}
|
|
332
|
+
return getClickGoStats(fpath);
|
|
333
|
+
}
|
|
334
|
+
else if (path.startsWith('/storage/')) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
else if (path.startsWith('/mounted/')) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
else if (path.startsWith('/package/')) {
|
|
341
|
+
if (!options.files) {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
if (options.files[fpath]) {
|
|
345
|
+
const file = options.files[fpath];
|
|
346
|
+
const date = new Date();
|
|
347
|
+
const ms = date.getTime();
|
|
348
|
+
let size = 0;
|
|
349
|
+
if (typeof file !== 'string') {
|
|
350
|
+
size = file.size;
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
size = new Blob([file]).size;
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
isFile: function () {
|
|
357
|
+
return true;
|
|
358
|
+
},
|
|
359
|
+
isDirectory: function () {
|
|
360
|
+
return false;
|
|
361
|
+
},
|
|
362
|
+
isSymbolicLink: function () {
|
|
363
|
+
return false;
|
|
364
|
+
},
|
|
365
|
+
'size': size,
|
|
366
|
+
'blksize': size,
|
|
367
|
+
'atimeMs': ms,
|
|
368
|
+
'mtimeMs': ms,
|
|
369
|
+
'ctimeMs': ms,
|
|
370
|
+
'birthtimeMs': ms,
|
|
371
|
+
'atime': date,
|
|
372
|
+
'mtime': date,
|
|
373
|
+
'ctime': date,
|
|
374
|
+
'birthtime': date
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (!fpath.endsWith('/')) {
|
|
378
|
+
fpath += '/';
|
|
379
|
+
}
|
|
380
|
+
for (const p in options.files) {
|
|
381
|
+
if (!p.startsWith(fpath)) {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const date = new Date();
|
|
385
|
+
const ms = date.getTime();
|
|
386
|
+
return {
|
|
387
|
+
isFile: function () {
|
|
388
|
+
return false;
|
|
389
|
+
},
|
|
390
|
+
isDirectory: function () {
|
|
391
|
+
return true;
|
|
392
|
+
},
|
|
393
|
+
isSymbolicLink: function () {
|
|
394
|
+
return false;
|
|
395
|
+
},
|
|
396
|
+
'size': 0,
|
|
397
|
+
'blksize': 0,
|
|
398
|
+
'atimeMs': ms,
|
|
399
|
+
'mtimeMs': ms,
|
|
400
|
+
'ctimeMs': ms,
|
|
401
|
+
'birthtimeMs': ms,
|
|
402
|
+
'atime': date,
|
|
403
|
+
'mtime': date,
|
|
404
|
+
'ctime': date,
|
|
405
|
+
'birthtime': date
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
else if (path.startsWith('/current/')) {
|
|
411
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
options.current = options.current.slice(0, -1);
|
|
415
|
+
return stats(options.current + fpath, options);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
exports.stats = stats;
|
|
423
|
+
function isDir(path, options = {}) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
425
|
+
const pstats = yield stats(path, options);
|
|
426
|
+
if (!pstats || !pstats.isDirectory()) {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
return pstats;
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
exports.isDir = isDir;
|
|
433
|
+
function isFile(path, options = {}) {
|
|
434
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
435
|
+
const pstats = yield stats(path, options);
|
|
436
|
+
if (!pstats || !pstats.isFile()) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
return pstats;
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
exports.isFile = isFile;
|
|
443
|
+
function mkdir(path, mode = 0o755, options = {}) {
|
|
444
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
445
|
+
path = tool.urlResolve('/', path);
|
|
446
|
+
if (yield isDir(path, options)) {
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
const fpath = path.slice(8);
|
|
450
|
+
if (path.startsWith('/clickgo/')) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
else if (path.startsWith('/storage/')) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
else if (path.startsWith('/mounted/')) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
else if (path.startsWith('/package/')) {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
else if (path.startsWith('/current/')) {
|
|
463
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
options.current = options.current.slice(0, -1);
|
|
467
|
+
return mkdir(options.current + fpath, mode, options);
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
exports.mkdir = mkdir;
|
|
475
|
+
function rmdir(path, options = {}) {
|
|
476
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
477
|
+
path = tool.urlResolve('/', path);
|
|
478
|
+
const fpath = path.slice(8);
|
|
479
|
+
if (path.startsWith('/clickgo/')) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
else if (path.startsWith('/storage/')) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
else if (path.startsWith('/mounted/')) {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
else if (path.startsWith('/package/')) {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
else if (path.startsWith('/current/')) {
|
|
492
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
options.current = options.current.slice(0, -1);
|
|
496
|
+
return rmdir(options.current + fpath, options);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
exports.rmdir = rmdir;
|
|
504
|
+
function rmdirDeep(path, options = {}) {
|
|
505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
506
|
+
path = tool.urlResolve('/', path);
|
|
507
|
+
if (!path.endsWith('/')) {
|
|
508
|
+
path += '/';
|
|
509
|
+
}
|
|
510
|
+
const list = yield readDir(path, options);
|
|
511
|
+
for (const item of list) {
|
|
512
|
+
const stat = yield stats(path + item.name, options);
|
|
513
|
+
if (!stat) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
if (stat.isDirectory()) {
|
|
517
|
+
const rtn = yield rmdirDeep(path + item.name, options);
|
|
518
|
+
if (!rtn) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
const rtn = yield unlink(path + item.name, options);
|
|
524
|
+
if (!rtn) {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return rmdir(path, options);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
exports.rmdirDeep = rmdirDeep;
|
|
533
|
+
function chmod(path, mod, options = {}) {
|
|
534
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
535
|
+
path = tool.urlResolve('/', path);
|
|
536
|
+
const fpath = path.slice(8);
|
|
537
|
+
if (path.startsWith('/clickgo/')) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
else if (path.startsWith('/storage/')) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
else if (path.startsWith('/mounted/')) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
else if (path.startsWith('/package/')) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
else if (path.startsWith('/current/')) {
|
|
550
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
options.current = options.current.slice(0, -1);
|
|
554
|
+
return chmod(options.current + fpath, mod, options);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
exports.chmod = chmod;
|
|
562
|
+
function rename(oldPath, newPath, options = {}) {
|
|
563
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
+
oldPath = tool.urlResolve('/', oldPath);
|
|
565
|
+
newPath = tool.urlResolve('/', newPath);
|
|
566
|
+
if (!oldPath.startsWith(newPath.slice(0, 9))) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const ofpath = oldPath.slice(8);
|
|
570
|
+
const nfpath = newPath.slice(8);
|
|
571
|
+
if (oldPath.startsWith('/clickgo/')) {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
else if (oldPath.startsWith('/storage/')) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
else if (oldPath.startsWith('/mounted/')) {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
else if (oldPath.startsWith('/package/')) {
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
else if (oldPath.startsWith('/current/')) {
|
|
584
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
options.current = options.current.slice(0, -1);
|
|
588
|
+
return rename(options.current + ofpath, options.current + nfpath, options);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
exports.rename = rename;
|
|
596
|
+
function readDir(path, options = {}) {
|
|
597
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
598
|
+
path = tool.urlResolve('/', path);
|
|
599
|
+
if (path === '/') {
|
|
600
|
+
const list = [
|
|
601
|
+
{
|
|
602
|
+
isFile: function () {
|
|
603
|
+
return false;
|
|
604
|
+
},
|
|
605
|
+
isDirectory: function () {
|
|
606
|
+
return true;
|
|
607
|
+
},
|
|
608
|
+
isSymbolicLink: function () {
|
|
609
|
+
return false;
|
|
610
|
+
},
|
|
611
|
+
'name': 'clickgo'
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
isFile: function () {
|
|
615
|
+
return false;
|
|
616
|
+
},
|
|
617
|
+
isDirectory: function () {
|
|
618
|
+
return true;
|
|
619
|
+
},
|
|
620
|
+
isSymbolicLink: function () {
|
|
621
|
+
return false;
|
|
622
|
+
},
|
|
623
|
+
'name': 'storage'
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
isFile: function () {
|
|
627
|
+
return false;
|
|
628
|
+
},
|
|
629
|
+
isDirectory: function () {
|
|
630
|
+
return true;
|
|
631
|
+
},
|
|
632
|
+
isSymbolicLink: function () {
|
|
633
|
+
return false;
|
|
634
|
+
},
|
|
635
|
+
'name': 'mounted'
|
|
636
|
+
}
|
|
637
|
+
];
|
|
638
|
+
if (options.files) {
|
|
639
|
+
list.push({
|
|
640
|
+
isFile: function () {
|
|
641
|
+
return false;
|
|
642
|
+
},
|
|
643
|
+
isDirectory: function () {
|
|
644
|
+
return true;
|
|
645
|
+
},
|
|
646
|
+
isSymbolicLink: function () {
|
|
647
|
+
return false;
|
|
648
|
+
},
|
|
649
|
+
'name': 'package'
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
if (options.current) {
|
|
653
|
+
list.push({
|
|
654
|
+
isFile: function () {
|
|
655
|
+
return false;
|
|
656
|
+
},
|
|
657
|
+
isDirectory: function () {
|
|
658
|
+
return false;
|
|
659
|
+
},
|
|
660
|
+
isSymbolicLink: function () {
|
|
661
|
+
return true;
|
|
662
|
+
},
|
|
663
|
+
'name': 'current'
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
return list;
|
|
667
|
+
}
|
|
668
|
+
if (!path.endsWith('/')) {
|
|
669
|
+
path += '/';
|
|
670
|
+
}
|
|
671
|
+
const fpath = path.slice(8);
|
|
672
|
+
if (path.startsWith('/clickgo/')) {
|
|
673
|
+
const list = [];
|
|
674
|
+
for (const item of clickgoFiles) {
|
|
675
|
+
if (!item.startsWith(fpath)) {
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
if (fpath === item) {
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
const rpath = item.slice(fpath.length);
|
|
682
|
+
if (rpath.includes('/')) {
|
|
683
|
+
if (rpath.endsWith('/')) {
|
|
684
|
+
if (rpath.slice(0, -1).includes('/')) {
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
list.push({
|
|
688
|
+
isFile: function () {
|
|
689
|
+
return false;
|
|
690
|
+
},
|
|
691
|
+
isDirectory: function () {
|
|
692
|
+
return true;
|
|
693
|
+
},
|
|
694
|
+
isSymbolicLink: function () {
|
|
695
|
+
return false;
|
|
696
|
+
},
|
|
697
|
+
'name': rpath.slice(0, -1)
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
list.push({
|
|
703
|
+
isFile: function () {
|
|
704
|
+
return true;
|
|
705
|
+
},
|
|
706
|
+
isDirectory: function () {
|
|
707
|
+
return false;
|
|
708
|
+
},
|
|
709
|
+
isSymbolicLink: function () {
|
|
710
|
+
return false;
|
|
711
|
+
},
|
|
712
|
+
'name': rpath
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
return list;
|
|
716
|
+
}
|
|
717
|
+
else if (path.startsWith('/storage/')) {
|
|
718
|
+
return [];
|
|
719
|
+
}
|
|
720
|
+
else if (path.startsWith('/mounted/')) {
|
|
721
|
+
return [];
|
|
722
|
+
}
|
|
723
|
+
else if (path.startsWith('/package/')) {
|
|
724
|
+
if (!options.files) {
|
|
725
|
+
return [];
|
|
726
|
+
}
|
|
727
|
+
const list = [];
|
|
728
|
+
const dirs = [];
|
|
729
|
+
for (const p in options.files) {
|
|
730
|
+
if (!p.startsWith(fpath)) {
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
const rpath = p.slice(fpath.length);
|
|
734
|
+
const sio = rpath.indexOf('/');
|
|
735
|
+
if (sio !== -1) {
|
|
736
|
+
const name = rpath.slice(0, sio);
|
|
737
|
+
if (!dirs.includes(name)) {
|
|
738
|
+
dirs.push(name);
|
|
739
|
+
list.push({
|
|
740
|
+
isFile: function () {
|
|
741
|
+
return false;
|
|
742
|
+
},
|
|
743
|
+
isDirectory: function () {
|
|
744
|
+
return true;
|
|
745
|
+
},
|
|
746
|
+
isSymbolicLink: function () {
|
|
747
|
+
return false;
|
|
748
|
+
},
|
|
749
|
+
'name': name
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
list.push({
|
|
755
|
+
isFile: function () {
|
|
756
|
+
return true;
|
|
757
|
+
},
|
|
758
|
+
isDirectory: function () {
|
|
759
|
+
return false;
|
|
760
|
+
},
|
|
761
|
+
isSymbolicLink: function () {
|
|
762
|
+
return false;
|
|
763
|
+
},
|
|
764
|
+
'name': rpath
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
return list;
|
|
768
|
+
}
|
|
769
|
+
else if (path.startsWith('/current/')) {
|
|
770
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
771
|
+
return [];
|
|
772
|
+
}
|
|
773
|
+
options.current = options.current.slice(0, -1);
|
|
774
|
+
return readDir(options.current + fpath, options);
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
return [];
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
exports.readDir = readDir;
|
|
782
|
+
function copyFolder(from, to, options = {}) {
|
|
783
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
784
|
+
from = tool.urlResolve('/', from);
|
|
785
|
+
to = tool.urlResolve('/', to);
|
|
786
|
+
if (!from.startsWith(to.slice(0, 9))) {
|
|
787
|
+
return 0;
|
|
788
|
+
}
|
|
789
|
+
const ffpath = from.slice(8);
|
|
790
|
+
const tfpath = from.slice(8);
|
|
791
|
+
if (from.startsWith('/clickgo/')) {
|
|
792
|
+
return 0;
|
|
793
|
+
}
|
|
794
|
+
else if (from.startsWith('/storage/')) {
|
|
795
|
+
return 0;
|
|
796
|
+
}
|
|
797
|
+
else if (from.startsWith('/mounted/')) {
|
|
798
|
+
return 0;
|
|
799
|
+
}
|
|
800
|
+
else if (from.startsWith('/package/')) {
|
|
801
|
+
return 0;
|
|
802
|
+
}
|
|
803
|
+
else if (from.startsWith('/current/')) {
|
|
804
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
805
|
+
return 0;
|
|
806
|
+
}
|
|
807
|
+
options.current = options.current.slice(0, -1);
|
|
808
|
+
return copyFolder(options.current + ffpath, options.current + tfpath, options);
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
return 0;
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
exports.copyFolder = copyFolder;
|
|
816
|
+
function copyFile(src, dest, options = {}) {
|
|
817
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
818
|
+
src = tool.urlResolve('/', src);
|
|
819
|
+
dest = tool.urlResolve('/', dest);
|
|
820
|
+
if (!src.startsWith(dest.slice(0, 9))) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
const sfpath = src.slice(8);
|
|
824
|
+
const dfpath = dest.slice(8);
|
|
825
|
+
if (src.startsWith('/clickgo/')) {
|
|
826
|
+
return false;
|
|
827
|
+
}
|
|
828
|
+
else if (src.startsWith('/storage/')) {
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
else if (src.startsWith('/mounted/')) {
|
|
832
|
+
return false;
|
|
833
|
+
}
|
|
834
|
+
else if (src.startsWith('/package/')) {
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
else if (src.startsWith('/current/')) {
|
|
838
|
+
if (!options.current || !options.current.endsWith('/')) {
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
options.current = options.current.slice(0, -1);
|
|
842
|
+
return copyFile(options.current + sfpath, options.current + dfpath, options);
|
|
843
|
+
}
|
|
844
|
+
else {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
exports.copyFile = copyFile;
|