Created
December 1, 2018 14:15
-
-
Save Sascha-T/a198ec80debcb89a11dc609ef7ea8855 to your computer and use it in GitHub Desktop.
OPENCOMPUTERS TapeUtility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local taped = require("component").tape_drive | |
local fs = require("component").filesystem | |
local a = {...} | |
taped.seek(-taped.getPosition()) | |
local r = "" | |
if taped.read(4) == "fsiz" then | |
while true do | |
local partdata = taped.read(1) | |
if tonumber(partdata) ~= nil then | |
r = r .. partdata | |
else | |
break | |
end | |
end | |
taped.seek(4) | |
local buf = "" | |
buf = taped.read(tonumber(r)) | |
local e = fs.open(a[1], "w") | |
fs.write(e, buf) | |
fs.close(e) | |
print("Wrote file to ".. a[1]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local taped = require("component").tape_drive | |
local fs = require("component").filesystem | |
local a = {...} | |
local h = fs.open(a[1]) | |
local buf = "" | |
repeat | |
local data = fs.read(h, math.huge) | |
buf = buf .. (data or "") | |
until not data | |
print("Writing...") | |
taped.seek(-taped.getPosition()) | |
taped.write("fsiz"..string.len(buf).."nfsiz") | |
taped.write(buf) | |
taped.write("nfileahead") | |
print("Done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment