forked from hkc/cc-stuff
1
0
Fork 0

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) local title = drive.read(117)
print(string.format("%d: %d + %d", i, offset, length)) print(string.format("%d: %d + %d", i, offset, length))
table.insert(table_of_contents, { table.insert(table_of_contents, {
title = "", -- TODO title = length and title or nil,
offset = offset, offset = offset,
length = length, length = length,
ending = offset + length ending = offset + length

View File

@ -49,8 +49,10 @@ with TemporaryDirectory(prefix="tapedrive") as tmpdir_str:
for i in range(48): for i in range(48):
name = (titles[i] if i < len(titles) else b"")[:117] name = (titles[i] if i < len(titles) else b"")[:117]
pos = positions[i] if i < len(titles) else (0, 0) pos = positions[i] if i < len(titles) else (0, 0)
written_bytes += fout.write(pos[0].to_bytes(4, "little")) if i < len(titles):
written_bytes += fout.write(pos[0].to_bytes(4, "little")) 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(name)
written_bytes += fout.write(b"\x00" * (117 - len(name))) written_bytes += fout.write(b"\x00" * (117 - len(name)))
if written_bytes != 6000: if written_bytes != 6000:

View File

@ -15,9 +15,9 @@ tape.stop()
tape.seek(-tape.getSize()) tape.seek(-tape.getSize())
tape.stop() tape.stop()
local req = http.get(args[1], {}, true) local req, err = http.get(args[1], {}, true)
if not req then if not req then
print("oopsie") print("oopsie: "..err)
return return
end end
@ -31,7 +31,7 @@ end
local written = 1 local written = 1
local _, y = term.getCursorPos() local _, y = term.getCursorPos()
while true do while true do
local chunk = req.read() local chunk = req.read(256)
if not chunk then if not chunk then
print("EOF") print("EOF")
break break