mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
plugin path expansion (nw)
This commit is contained in:
parent
d7bf380fd9
commit
72a499b54a
@ -1,11 +1,30 @@
|
||||
-- license:BSD-3-Clause
|
||||
-- copyright-holders:Miodrag Milanovic
|
||||
require('lfs')
|
||||
local dir = manager:options().entries.pluginspath:value()
|
||||
package.path = dir .. "/?.lua;" .. dir .. "/?/init.lua"
|
||||
|
||||
local function env_replace(str)
|
||||
local pathsep = package.config:sub(1,1)
|
||||
local function dorep(val)
|
||||
ret = os.getenv(val)
|
||||
if ret then
|
||||
return ret
|
||||
end
|
||||
return val
|
||||
end
|
||||
|
||||
if pathsep == '\\' then
|
||||
str = str:gsub("%%(%w+)%%", dorep)
|
||||
else
|
||||
str = str:gsub("%$(%w+)", dorep)
|
||||
end
|
||||
return str
|
||||
end
|
||||
local dir = env_replace(manager:options().entries.pluginspath:value())
|
||||
|
||||
package.path = package.path .. ";" .. dir .. "/?.lua;" .. dir .. "/?/init.lua"
|
||||
|
||||
local json = require('json')
|
||||
function readAll(file)
|
||||
local function readAll(file)
|
||||
local f = io.open(file, "rb")
|
||||
local content = f:read("*all")
|
||||
f:close()
|
||||
|
@ -160,7 +160,9 @@ void mame_machine_manager::start_luaengine()
|
||||
osd_file::error filerr = file.open("boot.lua");
|
||||
if (filerr == osd_file::error::NONE)
|
||||
{
|
||||
m_lua->load_script(file.fullpath());
|
||||
std::string exppath;
|
||||
osd_subst_env(exppath, std::string(file.fullpath()));
|
||||
m_lua->load_script(exppath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ plugin_options::plugin_options()
|
||||
void plugin_options::parse_json(std::string path)
|
||||
{
|
||||
// first try to open as a directory
|
||||
osd_subst_env(path, path);
|
||||
osd::directory::ptr directory = osd::directory::open(path);
|
||||
if (directory)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user