mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-14 16:34:04 +09:00
moving everything neatly into the assets directory
This commit is contained in:
20
assets/disk0/tvdos/bin/hexdump.js
Normal file
20
assets/disk0/tvdos/bin/hexdump.js
Normal file
@@ -0,0 +1,20 @@
|
||||
if (exec_args[1] === undefined) {
|
||||
printerrln("Usage: hexdump <file>")
|
||||
return 1;
|
||||
}
|
||||
|
||||
let fileOpened = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(exec_args[1]).string, "R");
|
||||
if (!fileOpened) {
|
||||
printerrln(_G.shell.resolvePathInput(exec_args[1]).string+": cannot open");
|
||||
return 1;
|
||||
}
|
||||
let fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
|
||||
let visible = "";
|
||||
|
||||
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')} `;
|
||||
}
|
||||
|
||||
println(visible);
|
||||
return 0;
|
||||
Reference in New Issue
Block a user