Skip to content

Commit

Permalink
update lfs detection
Browse files Browse the repository at this point in the history
  • Loading branch information
skywind3000 committed Jun 29, 2020
1 parent 1b9630e commit 65bfbf8
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions z.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2691,20 +2691,24 @@ end
-- LFS optimize
-----------------------------------------------------------------------
os.lfs = {}
os.lfs.disable = os.getenv('_ZL_DISABLE_LFS')
if os.lfs.disable == nil then
os.lfs.status, os.lfs.pkg = pcall(require, 'lfs')
if os.lfs.status then
local lfs = os.lfs.pkg
os.path.exists = function (name)
return lfs.attributes(name) and true or false
end
os.path.isdir = function (name)
local mode = lfs.attributes(name)
if not mode then
return false
os.lfs.enable = os.getenv('_ZL_USE_LFS')
os.lfs.enable = '1'
if os.lfs.enable ~= nil then
local m = string.lower(os.lfs.enable)
if (m == '1' or m == 'yes' or m == 'true' or m == 't') then
os.lfs.status, os.lfs.pkg = pcall(require, 'lfs')
if os.lfs.status then
local lfs = os.lfs.pkg
os.path.exists = function (name)
return lfs.attributes(name) and true or false
end
os.path.isdir = function (name)
local mode = lfs.attributes(name)
if not mode then
return false
end
return (mode.mode == 'directory') and true or false
end
return (mode.mode == 'directory') and true or false
end
end
end
Expand Down

0 comments on commit 65bfbf8

Please sign in to comment.