plugin path expansion (nw)

This commit is contained in:
cracyc 2016-07-09 15:11:30 -05:00
parent d7bf380fd9
commit 72a499b54a
3 changed files with 26 additions and 4 deletions

View File

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

View File

@ -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());
}
}
}

View File

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