chiliui
chiliui copied to clipboard
api_chili.lua GetDirectory returns the path with the file in it
GetDirectory only works if source path is for example "LuaUI/Widgets/" and not if it is for example "LuaUI\Widgets" Not sure about Linux but on Windows debug and debug.getinfo(1).source will have backslash ( \ )
local source = debug and debug.getinfo(1).source
local DIR = GetDirectory(source)
local function GetDirectory(filepath)
return filepath and filepath:gsub("(.*/)(.*)", "%1")
end
Possible fix:
local function GetDirectory(filepath)
local split,isFSlash = filepath:gsub("(.*/)(.*)", "%2")
if isFSlash == 0 then
return filepath:gsub("(.*\\)(.*)", "%1")
end
return filepath:gsub(split,"")
end