1
0
mirror of https://github.com/skywind3000/z.lua synced 2026-03-16 20:59:48 +00:00

update lfs detection

This commit is contained in:
skywind3000
2020-06-29 19:40:55 +08:00
parent 1b9630e72d
commit 65bfbf8dfb

30
z.lua
View File

@@ -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