summaryrefslogtreecommitdiff
path: root/xmake/core/base/io.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-18 22:44:49 +0800
committerruki <[email protected]>2020-03-18 10:28:58 +0800
commit5c3a3168f645495cc5d2ab3472d1e3d366bbb004 (patch)
tree1df244c8d97731a8c94533100a043d90f523f007 /xmake/core/base/io.lua
parent0c872f6357951a3074c0b03cab8c53d66fe51839 (diff)
decrease to call string.find_last
Diffstat (limited to 'xmake/core/base/io.lua')
-rw-r--r--xmake/core/base/io.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua
index 257e3ad3f..264afe59c 100644
--- a/xmake/core/base/io.lua
+++ b/xmake/core/base/io.lua
@@ -37,7 +37,6 @@ io._stdfile = io._stdfile or io.stdfile
-- new a file
function _file.new(filepath, cdata, isstdfile)
local file = table.inherit(_file)
- file._NAME = path.filename(filepath)
file._PATH = isstdfile and filepath or path.absolute(filepath)
file._FILE = cdata
setmetatable(file, _file)
@@ -46,6 +45,9 @@ end
-- get the file name
function _file:name()
+ if not self._NAME then
+ self._NAME = path.filename(self:path())
+ end
return self._NAME
end
@@ -295,7 +297,6 @@ end
-- new an filelock
function _filelock.new(lockpath, lock)
local filelock = table.inherit(_filelock)
- filelock._NAME = path.filename(lockpath)
filelock._PATH = path.absolute(lockpath)
filelock._LOCK = lock
filelock._LOCKED_NUM = 0
@@ -305,6 +306,9 @@ end
-- get the filelock name
function _filelock:name()
+ if not self._NAME then
+ self._NAME = path.filename(self:path())
+ end
return self._NAME
end