This commit is contained in:
Namhyeon Go 2020-11-25 12:32:04 +09:00
parent 1dd049f015
commit d3c4292b6f
3 changed files with 69 additions and 45 deletions

18
app.js
View File

@ -144,7 +144,7 @@ function require(FN) {
T = objStream.readText(); T = objStream.readText();
objStream.close(); objStream.close();
} catch (e) { } catch (e) {
console.error("LOAD ERROR! " + e.number + ", " + e.description + ", FN=" + FN, 1); console.error("LOAD ERROR! ", e.number, ", ", e.description, ", FN=", FN);
return; return;
} }
@ -153,7 +153,7 @@ function require(FN) {
try { try {
cache[FN] = eval(T); cache[FN] = eval(T);
} catch (e) { } catch (e) {
console.error("PARSE ERROR! " + e.number + ", " + e.description + ", FN=" + FN, 1); console.error("PARSE ERROR! ", e.number, ", ", e.description, ", FN=", FN);
} }
// check type of callback return // check type of callback return
@ -189,10 +189,10 @@ function init_console() {
exit(exitstatus); exit(exitstatus);
} }
} else { } else {
console.error("Error, missing main entry point in " + name + ".js", 1); console.error("Error, missing main entry point in ", name, ".js");
} }
} else { } else {
console.error("Error, cannot find " + name + ".js", 1); console.error("Error, cannot find ", name, ".js");
} }
} }
} }
@ -212,17 +212,17 @@ function init_window(name, args, w, h) {
// "load app"; // "load app";
if (app) { if (app) {
if (app.main) { if (app.main) {
var exitstatus = app.main.call(app, args); var exitStatus = app.main.call(app, args);
if (exitstatus > 0) { if (exitStatus > 0) {
console.error("error"); console.error("error");
exit(exitstatus); exit(exitStatus);
} }
} else { } else {
console.error("Error, missing main entry point in " + name + ".js"); console.error("Error, missing main entry point in ", name, ".js");
exit(1); exit(1);
} }
} else { } else {
console.error("Error, cannot find " + name + ".js"); console.error("Error, cannot find ", name, ".js");
exit(1); exit(1);
} }
} }

View File

@ -162,61 +162,85 @@ var FileObject = function() {
}; };
this.remove = function() { this.remove = function() {
if (this.isFile) { try {
return this.interface.DeleteFile(this.filename); if (this.isFile) {
} else { return this.interface.DeleteFile(this.filename);
return this.interface.DeleteFolder(this.filename); } else {
return this.interface.DeleteFolder(this.filename);
}
} catch (e) {
console.error("FileObject.remove() -> ", e.message);
} }
}; };
this.moveTo = function(dst) { this.moveTo = function(dst) {
if (this.isFile) { try {
return this.interface.MoveFile(this.filename, dst); if (this.isFile) {
} else { return this.interface.MoveFile(this.filename, dst);
return this.interface.MoveFolder(this.filename, dst); } else {
return this.interface.MoveFolder(this.filename, dst);
}
} catch (e) {
console.error("FileObject.moveTo() -> ", e.message);
} }
}; };
this.read = function() { this.read = function() {
if (this.isFile) { try {
return readFile(this.filename, this.charset); if (this.isFile) {
return readFile(this.filename, this.charset);
}
} catch (e) {
console.error("FileObject.read() -> ", e.message);
} }
}; };
this.write = function(content) { this.write = function(content) {
if (this.isFile) { try {
return writeFile(this.filename, content, this.charset); if (this.isFile) {
return writeFile(this.filename, content, this.charset);
}
} catch (e) {
console.error("FileObject.write() -> ", e.message);
} }
}; };
this.chown = function(username) { this.chown = function(username) {
if (this.isFile) { try {
//require("lib/shell").run(["cacls", this.filename, "/G", user + ":F"]); if (this.isFile) {
require("lib/shell").run([ //require("lib/shell").run(["cacls", this.filename, "/G", user + ":F"]);
"icacls", require("lib/shell").run([
"/C", "icacls",
"/q", "/C",
this.filename, "/q",
"/grant", this.filename,
username + ":(F)" "/grant",
]); username + ":(F)"
} else if (this.isDirectory) { ]);
//require("lib/shell").run(["cacls", this.filename, "/G", user + ":F"]); } else if (this.isDirectory) {
require("lib/shell").run([ //require("lib/shell").run(["cacls", this.filename, "/G", user + ":F"]);
"icacls", require("lib/shell").run([
"/C", "icacls",
"/t", "/C",
"/q", "/t",
this.filename, "/q",
"/grant", this.filename,
username + ":(F)" "/grant",
]); username + ":(F)"
]);
}
} catch (e) {
console.error("FileObject.chown() -> ", e.message);
} }
}; };
this.mkdir = function() { this.mkdir = function() {
if (this.isDirectory) { try {
return this.interface.CreateFolder(this.filename); if (this.isDirectory) {
return this.interface.CreateFolder(this.filename);
}
} catch (e) {
console.error("FileObject.mkdir() -> ", e.message);
} }
}; };

View File

@ -25,11 +25,11 @@ global.console._echo = function(args, type) {
case "info": case "info":
heading = "Information"; heading = "Information";
icon = "info"; icon = "info";
break;
default: default:
heading = "Success"; heading = "Success";
icon = "success"; icon = "success";
return;
} }
try { try {