Strip DF folder from Ruby script paths

Fixes #1146 (temporarily, see #1147)
develop
lethosor 2017-08-08 20:08:07 -04:00
parent 95aa5bbb47
commit 08656a3ca7
1 changed files with 9 additions and 0 deletions

@ -388,6 +388,15 @@ static command_result runRubyScript(color_ostream &out, PluginManager *plug_mgr,
if (!plug_mgr->ruby || !plug_mgr->ruby->is_enabled())
return CR_FAILURE;
// ugly temporary patch for https://github.com/DFHack/dfhack/issues/1146
string cwd = Filesystem::getcwd();
if (filename.find(cwd) == 0)
{
filename = filename.substr(cwd.size());
while (!filename.empty() && (filename[0] == '/' || filename[0] == '\\'))
filename = filename.substr(1);
}
std::string rbcmd = "$script_args = [";
for (size_t i = 0; i < args.size(); i++)
rbcmd += "'" + args[i] + "', ";