mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 19:56:17 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8.9
This commit is contained in:
commit
cfd12357bd
@ -263,6 +263,8 @@ function term.readKeyboard(ops)
|
||||
input:update(0)
|
||||
elseif char>=32 then
|
||||
c=unicode.char(char)
|
||||
else
|
||||
hints.cache = backup_cache
|
||||
end
|
||||
end
|
||||
if c then input:update(c) end
|
||||
@ -491,7 +493,8 @@ function --[[@delayloaded-start@]] term.internal.tab(input,hints)
|
||||
hints.cache.i=-1
|
||||
end
|
||||
local c=hints.cache
|
||||
c.i=(c.i+1)%math.max(#c,1)
|
||||
local change = kb.isShiftDown(term.keyboard().address) and -1 or 1
|
||||
c.i=(c.i+change)%math.max(#c,1)
|
||||
local next=c[c.i+1]
|
||||
if next then
|
||||
local tail = unicode.wlen(input.data) - input.index - 1
|
||||
|
@ -42,8 +42,10 @@ if filename == "" then
|
||||
end
|
||||
filename = shell.resolve(filename)
|
||||
|
||||
local preexisted
|
||||
if fs.exists(filename) then
|
||||
if not options.f or not os.remove(filename) then
|
||||
preexisted = true
|
||||
if not options.f then
|
||||
if not options.Q then
|
||||
io.stderr:write("file already exists")
|
||||
end
|
||||
@ -51,13 +53,15 @@ if fs.exists(filename) then
|
||||
end
|
||||
end
|
||||
|
||||
local f, reason = io.open(filename, "wb")
|
||||
local f, reason = io.open(filename, "a")
|
||||
if not f then
|
||||
if not options.Q then
|
||||
io.stderr:write("failed opening file for writing: " .. reason)
|
||||
end
|
||||
return nil, "failed opening file for writing: " .. reason -- for programs using wget as a function
|
||||
end
|
||||
f:close()
|
||||
f = nil
|
||||
|
||||
if not options.q then
|
||||
io.write("Downloading... ")
|
||||
@ -66,6 +70,10 @@ local result, response = pcall(internet.request, url)
|
||||
if result then
|
||||
local result, reason = pcall(function()
|
||||
for chunk in response do
|
||||
if not f then
|
||||
f, reason = io.open(filename, "wb")
|
||||
assert(f, "failed opening file for writing: " .. tostring(reason))
|
||||
end
|
||||
f:write(chunk)
|
||||
end
|
||||
end)
|
||||
@ -73,8 +81,12 @@ if result then
|
||||
if not options.q then
|
||||
io.stderr:write("failed.\n")
|
||||
end
|
||||
f:close()
|
||||
fs.remove(filename)
|
||||
if f then
|
||||
f:close()
|
||||
if not preexisted then
|
||||
fs.remove(filename)
|
||||
end
|
||||
end
|
||||
if not options.Q then
|
||||
io.stderr:write("HTTP request failed: " .. reason .. "\n")
|
||||
end
|
||||
@ -83,8 +95,11 @@ if result then
|
||||
if not options.q then
|
||||
io.write("success.\n")
|
||||
end
|
||||
|
||||
if f then
|
||||
f:close()
|
||||
end
|
||||
|
||||
f:close()
|
||||
if not options.q then
|
||||
io.write("Saved data to " .. filename .. "\n")
|
||||
end
|
||||
@ -92,11 +107,9 @@ else
|
||||
if not options.q then
|
||||
io.write("failed.\n")
|
||||
end
|
||||
f:close()
|
||||
fs.remove(filename)
|
||||
if not options.Q then
|
||||
io.stderr:write("HTTP request failed: " .. response .. "\n")
|
||||
end
|
||||
return nil, response -- for programs using wget as a function
|
||||
end
|
||||
return true -- for programs using wget as a function
|
||||
return true -- for programs using wget as a function
|
||||
|
Loading…
x
Reference in New Issue
Block a user