Tape fixes

This commit is contained in:
Casey 2023-10-17 16:03:16 +03:00
parent f4fb54c23a
commit 99d5f95757
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
3 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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:

View File

@ -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