Monkeypatch script fixes
This commit is contained in:
parent
e929e4a75c
commit
8394f1adca
1 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
local fii = require("ffi")
|
local ffi = require("ffi")
|
||||||
|
|
||||||
if ffi.os ~= "Windows" then
|
if ffi.os ~= "Windows" then
|
||||||
return
|
return
|
||||||
|
@ -77,6 +77,7 @@ end
|
||||||
local function execresult(stat)
|
local function execresult(stat)
|
||||||
if stat == -1 then
|
if stat == -1 then
|
||||||
return fileresult(0, nil)
|
return fileresult(0, nil)
|
||||||
|
end
|
||||||
|
|
||||||
if stat == 0 then
|
if stat == 0 then
|
||||||
return true, "exit", stat
|
return true, "exit", stat
|
||||||
|
@ -90,10 +91,13 @@ local orig_remove = os.remove
|
||||||
local orig_execute = os.execute
|
local orig_execute = os.execute
|
||||||
|
|
||||||
function io.open(fname, mode)
|
function io.open(fname, mode)
|
||||||
local wfname = widen(path)
|
local wfname = widen(fname)
|
||||||
|
if not mode then
|
||||||
|
mode = "r"
|
||||||
|
end
|
||||||
local wmode = widen(mode)
|
local wmode = widen(mode)
|
||||||
|
|
||||||
local file = assert(open("nul", "rb"))
|
local file = assert(orig_open("nul", "rb"))
|
||||||
if ffi.C._wfreopen(wfname, wmode, file) == nil then
|
if ffi.C._wfreopen(wfname, wmode, file) == nil then
|
||||||
local msg, errno = select(2, file:close())
|
local msg, errno = select(2, file:close())
|
||||||
return nil, fname .. ": " .. msg, errno
|
return nil, fname .. ": " .. msg, errno
|
||||||
|
@ -111,7 +115,7 @@ function os.rename(oldname, newname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function os.remove(fname)
|
function os.remove(fname)
|
||||||
local wfname = widen(path)
|
local wfname = widen(fname)
|
||||||
|
|
||||||
local stat = ffi.C._wremove(wfname)
|
local stat = ffi.C._wremove(wfname)
|
||||||
return fileresult(stat, fname)
|
return fileresult(stat, fname)
|
||||||
|
|
Loading…
Reference in a new issue