修复 大小写文件名导致重复载入
This commit is contained in:
parent
9e47dffa27
commit
d5916c5462
|
@ -1,7 +1,7 @@
|
|||
--[[
|
||||
@Author : baidwwy
|
||||
@Date : 2020-09-22 19:49:01
|
||||
@LastEditTime : 2021-04-11 04:28:34
|
||||
@LastEditTime : 2021-05-02 11:02:57
|
||||
--]]
|
||||
require("ggelua")
|
||||
io.stdout:setvbuf('no',0)
|
||||
|
@ -37,7 +37,7 @@ package.cpath = nil
|
|||
setmetatable(package, {
|
||||
__newindex = function (t,k,v)
|
||||
if v and k=='path' then
|
||||
lpath = v:lower():gsub('\\','/')
|
||||
lpath = v:upper():gsub('\\','/')
|
||||
lpath_ = 分割路径(lpath)
|
||||
elseif k=='cpath' then
|
||||
cpath = v
|
||||
|
@ -71,7 +71,7 @@ local function 处理路径(path)
|
|||
-- end
|
||||
-- path = table.concat(t, "/")
|
||||
|
||||
path = path:lower()--小写
|
||||
path = path:upper()--大写
|
||||
path = path:gsub('%.','/')
|
||||
path = path:gsub('\\','/')
|
||||
return path
|
||||
|
@ -160,17 +160,30 @@ local function 搜索路径(path)
|
|||
end
|
||||
end
|
||||
|
||||
local loaded = setmetatable({}, {__mode="v"})
|
||||
table.insert(package.searchers, 1, function (path)
|
||||
path = 处理路径(path)
|
||||
path = 搜索路径(path)
|
||||
if path then
|
||||
local r,err = load(读取文件(path),path)
|
||||
return r or error(err,2)
|
||||
local npath = 处理路径(path)
|
||||
if loaded[npath]~=nil then
|
||||
return function ()
|
||||
return loaded[npath]
|
||||
end
|
||||
end
|
||||
local fpath = 搜索路径(npath)
|
||||
if fpath then
|
||||
return function ()
|
||||
local r,err = load(读取文件(fpath),fpath)
|
||||
if err then
|
||||
return error(err,2)
|
||||
end
|
||||
local r = r()
|
||||
loaded[npath] = r==nil and true or r
|
||||
return loaded[npath]
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function gge.require(path,env,...)
|
||||
path = path:gsub('\\','/'):lower()
|
||||
path = path:gsub('\\','/'):upper()
|
||||
local data = 读取文件(path)
|
||||
if data then
|
||||
return assert(load(data,path,"bt",env))(...)
|
||||
|
|
Loading…
Reference in New Issue