From 99d5f95757896738d8fc797532a21987b664bb56 Mon Sep 17 00:00:00 2001 From: hkc Date: Tue, 17 Oct 2023 16:03:16 +0300 Subject: [PATCH] Tape fixes --- tape-playlist.lua | 2 +- tape-playlist.py | 6 ++++-- tapeget.lua | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tape-playlist.lua b/tape-playlist.lua index a03d408..771a04c 100644 --- a/tape-playlist.lua +++ b/tape-playlist.lua @@ -49,7 +49,7 @@ function() local title = drive.read(117) print(string.format("%d: %d + %d", i, offset, length)) table.insert(table_of_contents, { - title = "", -- TODO + title = length and title or nil, offset = offset, length = length, ending = offset + length diff --git a/tape-playlist.py b/tape-playlist.py index 3c65914..89ec17b 100644 --- a/tape-playlist.py +++ b/tape-playlist.py @@ -49,8 +49,10 @@ with TemporaryDirectory(prefix="tapedrive") as tmpdir_str: for i in range(48): name = (titles[i] if i < len(titles) else b"")[:117] pos = positions[i] if i < len(titles) else (0, 0) - written_bytes += fout.write(pos[0].to_bytes(4, "little")) - written_bytes += fout.write(pos[0].to_bytes(4, "little")) + if i < len(titles): + print(f"{i:2d} {pos[0]} + {pos[1]}") + written_bytes += fout.write(pos[0].to_bytes(4, "big")) + written_bytes += fout.write(pos[1].to_bytes(4, "big")) written_bytes += fout.write(name) written_bytes += fout.write(b"\x00" * (117 - len(name))) if written_bytes != 6000: diff --git a/tapeget.lua b/tapeget.lua index f567d04..a85a5e7 100644 --- a/tapeget.lua +++ b/tapeget.lua @@ -15,9 +15,9 @@ tape.stop() tape.seek(-tape.getSize()) tape.stop() -local req = http.get(args[1], {}, true) +local req, err = http.get(args[1], {}, true) if not req then - print("oopsie") + print("oopsie: "..err) return end @@ -31,7 +31,7 @@ end local written = 1 local _, y = term.getCursorPos() while true do - local chunk = req.read() + local chunk = req.read(256) if not chunk then print("EOF") break