Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit efeb839

Browse files
committed
Feat: new file route
1 parent 236ec53 commit efeb839

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/routers/file_router.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ routerApp.on("file/status", (ctx, data) => {
4747
}
4848
});
4949

50+
// Create a new file
51+
routerApp.on("file/touch", (ctx, data) => {
52+
try {
53+
const target = data.target;
54+
const fileManager = getFileManager(data.instanceUuid);
55+
fileManager.newFile(target);
56+
protocol.response(ctx, true);
57+
} catch (error) {
58+
protocol.responseError(ctx, error);
59+
}
60+
});
61+
5062
// Create a directory
5163
routerApp.on("file/mkdir", (ctx, data) => {
5264
try {

src/service/system_file.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ export default class FileManager {
109109
return await fs.writeFile(absPath, buf);
110110
}
111111

112+
async newFile(fileName: string){
113+
const target = this.toAbsolutePath(fileName)
114+
console.log(target)
115+
fs.createFile(target)
116+
}
117+
112118
async copy(target1: string, target2: string) {
113119
if (!this.checkPath(target2) || !this.check(target1)) throw new Error(ERROR_MSG_01);
114120
const targetPath = this.toAbsolutePath(target1);

0 commit comments

Comments
 (0)