forked from mirror/MCSM-Daemon
Feat: new file route
This commit is contained in:
parent
236ec53d40
commit
efeb8394c3
@ -47,6 +47,18 @@ routerApp.on("file/status", (ctx, data) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Create a new file
|
||||
routerApp.on("file/touch", (ctx, data) => {
|
||||
try {
|
||||
const target = data.target;
|
||||
const fileManager = getFileManager(data.instanceUuid);
|
||||
fileManager.newFile(target);
|
||||
protocol.response(ctx, true);
|
||||
} catch (error) {
|
||||
protocol.responseError(ctx, error);
|
||||
}
|
||||
});
|
||||
|
||||
// Create a directory
|
||||
routerApp.on("file/mkdir", (ctx, data) => {
|
||||
try {
|
||||
|
@ -109,6 +109,12 @@ export default class FileManager {
|
||||
return await fs.writeFile(absPath, buf);
|
||||
}
|
||||
|
||||
async newFile(fileName: string){
|
||||
const target = this.toAbsolutePath(fileName)
|
||||
console.log(target)
|
||||
fs.createFile(target)
|
||||
}
|
||||
|
||||
async copy(target1: string, target2: string) {
|
||||
if (!this.checkPath(target2) || !this.check(target1)) throw new Error(ERROR_MSG_01);
|
||||
const targetPath = this.toAbsolutePath(target1);
|
||||
|
Loading…
Reference in New Issue
Block a user