From 803b86ce43beb7609c617ce94e89ce6d8084baf9 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 11 May 2023 20:19:49 +0900 Subject: [PATCH] some new commands; lfs wip --- assets/disk0/tvdos/bin/gzip.js | 7 ++++--- assets/disk0/tvdos/bin/lfs.js | 21 +++++++++++++++++++++ assets/disk0/tvdos/bin/tee.js | 13 +++++++++++++ assets/disk0/tvdos/bin/writeto.js | 11 +++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 assets/disk0/tvdos/bin/lfs.js create mode 100644 assets/disk0/tvdos/bin/tee.js create mode 100644 assets/disk0/tvdos/bin/writeto.js diff --git a/assets/disk0/tvdos/bin/gzip.js b/assets/disk0/tvdos/bin/gzip.js index 9cf39a7..8c628b2 100644 --- a/assets/disk0/tvdos/bin/gzip.js +++ b/assets/disk0/tvdos/bin/gzip.js @@ -1,13 +1,14 @@ function printUsage() { - println(`Usage: gzip [-c] [-d] file + println(`Compresses or de-compresses (with -D flag) a file in-place, or to stdout if -C flag is set. +Usage: gzip [-c] [-d] file To compress a file, replacing it with a gzipped compressed version: gzip file.ext To decompress a file, replacing it with the original uncompressed version: gzip -d file.ext.gz To compress a file specifying the output filename: - gzip -c file.ext > compressed_file.ext.gz + gzip -c file.ext | writeto compressed_file.ext.gz To decompress a gzipped file specifying the output filename: - gzip -c -d file.ext.gz > uncompressed_file.ext`) + gzip -c -d file.ext.gz | writeto uncompressed_file.ext`) } if (exec_args[1] === undefined) { diff --git a/assets/disk0/tvdos/bin/lfs.js b/assets/disk0/tvdos/bin/lfs.js new file mode 100644 index 0000000..86694ec --- /dev/null +++ b/assets/disk0/tvdos/bin/lfs.js @@ -0,0 +1,21 @@ +function printUsage() { + println(`Collects files under a directory into a single archive. +Usage: lfs [-c/-x/-t] dest.lfs path\\to\\source +To collect a directory into myarchive.lfs: + lfs -c myarchive.lfs path\\to\\directory +To extract an archive to path\\to\\my\\files: + lfs -x myarchive.lfs \\path\\to\\my\\files +To list the collected files: + lfs -t`) +} + +const option = exec_args[1] +const lfsPath = exec_args[2] +const dirPath = exec_args[3] + + +if (option === undefined || lfsPath === undefined || option.toUpperCase() != "-T" && dirPath === undefined) { + printUsage() + return 0 +} + diff --git a/assets/disk0/tvdos/bin/tee.js b/assets/disk0/tvdos/bin/tee.js new file mode 100644 index 0000000..90f5e5e --- /dev/null +++ b/assets/disk0/tvdos/bin/tee.js @@ -0,0 +1,13 @@ +if (exec_args[1] === undefined) { + println("Usage: after a pipe,\n tee filename") + return 0 +} + +if (!_G.shell.hasPipe()) { + println("Pipe not opened") + return 1 +} + +let txt = _G.shell.getPipe() +files.open(_G.shell.resolvePathInput(exec_args[1]).full).swrite(txt) +print(txt) \ No newline at end of file diff --git a/assets/disk0/tvdos/bin/writeto.js b/assets/disk0/tvdos/bin/writeto.js new file mode 100644 index 0000000..75d131e --- /dev/null +++ b/assets/disk0/tvdos/bin/writeto.js @@ -0,0 +1,11 @@ +if (exec_args[1] === undefined) { + println("Usage: after a pipe,\n writeto filename") + return 0 +} + +if (!_G.shell.hasPipe()) { + println("Pipe not opened") + return 1 +} + +files.open(_G.shell.resolvePathInput(exec_args[1]).full).swrite(_G.shell.getPipe()) \ No newline at end of file