mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-11 23:34:04 +09:00
getting rid of old filesystem functions
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user