forked from mirror/MCSM-Daemon
Merge pull request #42 from DragoSpiro98/master
Feat: Route reference for file manager to create a new empty file
This commit is contained in:
commit
e1928741a0
@ -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