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,34 +162,51 @@ var FileObject = function() {
}; };
this.remove = function() { this.remove = function() {
try {
if (this.isFile) { if (this.isFile) {
return this.interface.DeleteFile(this.filename); return this.interface.DeleteFile(this.filename);
} else { } else {
return this.interface.DeleteFolder(this.filename); return this.interface.DeleteFolder(this.filename);
} }
} catch (e) {
console.error("FileObject.remove() -> ", e.message);
}
}; };
this.moveTo = function(dst) { this.moveTo = function(dst) {
try {
if (this.isFile) { if (this.isFile) {
return this.interface.MoveFile(this.filename, dst); return this.interface.MoveFile(this.filename, dst);
} else { } else {
return this.interface.MoveFolder(this.filename, dst); return this.interface.MoveFolder(this.filename, dst);
} }
} catch (e) {
console.error("FileObject.moveTo() -> ", e.message);
}
}; };
this.read = function() { this.read = function() {
try {
if (this.isFile) { if (this.isFile) {
return readFile(this.filename, this.charset); return readFile(this.filename, this.charset);
} }
} catch (e) {
console.error("FileObject.read() -> ", e.message);
}
}; };
this.write = function(content) { this.write = function(content) {
try {
if (this.isFile) { if (this.isFile) {
return writeFile(this.filename, content, this.charset); return writeFile(this.filename, content, this.charset);
} }
} catch (e) {
console.error("FileObject.write() -> ", e.message);
}
}; };
this.chown = function(username) { this.chown = function(username) {
try {
if (this.isFile) { if (this.isFile) {
//require("lib/shell").run(["cacls", this.filename, "/G", user + ":F"]); //require("lib/shell").run(["cacls", this.filename, "/G", user + ":F"]);
require("lib/shell").run([ require("lib/shell").run([
@ -212,12 +229,19 @@ var FileObject = function() {
username + ":(F)" username + ":(F)"
]); ]);
} }
} catch (e) {
console.error("FileObject.chown() -> ", e.message);
}
}; };
this.mkdir = function() { this.mkdir = function() {
try {
if (this.isDirectory) { if (this.isDirectory) {
return this.interface.CreateFolder(this.filename); return this.interface.CreateFolder(this.filename);
} }
} catch (e) {
console.error("FileObject.mkdir() -> ", e.message);
}
}; };
this.close = function() { this.close = function() {

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 {