View difference between Paste ID: 572pLrwj and BEGcR5XY
SHOW: | | - or go back to the newest paste.
1
local tArg = {...}
2
local fileName = tArg[1]
3
local tapeName = tArg[2]
4
local tape = peripheral.find("tape_drive")
5-
local file = fs.open(fs.combine(shell.dir(),fileName), "rb")
5+
local file
6
if fileName:sub(1,8) == "https://" then
7-
tape.seek(-2^20)
7+
	file = http.get(fileName)
8
else
9
	file = fs.open(fs.combine(shell.dir(),fileName), "r")
10
end
11
local byte = 0
12
tape.seek(-tape.getPosition())
13
if tapeName then
14
    tape.setLabel(tapeName)
15
end
16
local counter = 0
17-
    tape.write(byte)
17+
18-
    if counter % 2048 == 0 then
18+
19
    byte = file.read()
20
    if not byte then break end
21
    counter = counter + 1
22
    tape.write(byte:byte())
23
    if counter == 4096 then
24
        counter = 0
25-
tape.seek(-2^20)
25+
26
        os.pullEvent("yield")
27
        write(".")
28
    end
29
end
30
tape.seek(-tape.getPosition())
31
file.close()
32
print("\nIt is written.")