summaryrefslogtreecommitdiff
path: root/xmake/core/base/io.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-08-19 23:54:32 +0800
committerruki <[email protected]>2019-08-19 17:27:13 +0800
commit905b289ecf007df7d30bcdcee927e46931639ea8 (patch)
treeaa0296aa54a9b349570a2d0f112c35806f3dc69e /xmake/core/base/io.lua
parent612dd5918297120bc7f0c2011fbbce90863fafaa (diff)
fix io.isatty
Diffstat (limited to 'xmake/core/base/io.lua')
-rw-r--r--xmake/core/base/io.lua19
1 files changed, 4 insertions, 15 deletions
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua
index aa00507f3..ac405dbac 100644
--- a/xmake/core/base/io.lua
+++ b/xmake/core/base/io.lua
@@ -37,7 +37,7 @@ io._stdfile = io._stdfile or io.stdfile
function _file.new(filepath, fileref)
local file = table.inherit(_file)
file._NAME = path.filename(filepath)
- file._PATH = filepath
+ file._PATH = path.absolute(filepath)
file._FILE = fileref
setmetatable(file, _file)
return file
@@ -149,7 +149,7 @@ function _file:isatty()
return false, string.format("file(%s) has been closed!", self:name())
end
local ok, errors = io.file_isatty(self._FILE)
- if not ok and errors then
+ if ok == nil and errors then
errors = string.format("file(%s): %s", self:name(), errors)
end
return ok, errors
@@ -204,7 +204,7 @@ end
function _filelock.new(lockpath, lock)
local filelock = table.inherit(_filelock)
filelock._NAME = path.filename(lockpath)
- filelock._PATH = lockpath
+ filelock._PATH = path.absolute(lockpath)
filelock._LOCK = lock
filelock._LOCKED_NUM = 0
setmetatable(filelock, _filelock)
@@ -308,8 +308,8 @@ end
-- read all lines from file
function io.lines(filepath, opt)
+ -- close on finished
opt = opt or {}
-
if opt.close_on_finished == nil then
opt.close_on_finished = true
end
@@ -317,7 +317,6 @@ function io.lines(filepath, opt)
-- open file
local file = io.open(filepath, "r", opt)
if not file then
- -- error
return function() return nil end
end
@@ -366,16 +365,6 @@ function io.flush()
return io.stdout:flush()
end
-function io.lines(filepath, opt)
- opt = opt or {}
- opt.close_on_finished = true
- local file, errors = io.open(filepath, 'r', opt)
- if file then
- return file:lines()
- end
- return file, errors
-end
-
-- write data to file
function io.writefile(filepath, data, opt)