getting rid of old filesystem functions

This commit is contained in:
minjaesong
2022-09-06 20:30:46 +09:00
parent 8232053695
commit 0d1e33f7e6
14 changed files with 102 additions and 47 deletions

View File

@@ -3,18 +3,30 @@ if (exec_args[1] === undefined) {
return 1;
}
let fileOpenedStatus = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(exec_args[1]).string, "R");
if (fileOpenedStatus != 0) {
let file = files.open(`${_G.shell.getCurrentDrive()}:/${_G.shell.resolvePathInput(exec_args[1]).string}`)
if (!file.exists) {
printerrln(_G.shell.resolvePathInput(exec_args[1]).string+": cannot open");
return fileOpenedStatus;
return 1;
}
let fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
let visible = "";
let fileContent = file.sread()
for (let k = 0; k < fileContent.length; k++) {
if (k > 0 && k % 16 == 0) visible += "\n";
visible += `${fileContent.charCodeAt(k).toString(16).toUpperCase().padStart(2, '0')} `;
for (let k = 0; k < fileContent.length; k += 16) {
for (let i = 0; i < 16; i++) {
let charCode = fileContent.charCodeAt(k+i)
if (!isNaN(charCode))
print(`${charCode.toString(16).toUpperCase().padStart(2, '0')} `)
else
print(` `)
}
print('| ')
for (let i = 0; i < 16; i++) {
let charCode = fileContent.charCodeAt(k+i)
if (!isNaN(charCode))
con.prnch(charCode)
else
con.prnch(0)
}
println()
}
println(visible);
return 0;