diff --git a/plugins/blueprint.cpp b/plugins/blueprint.cpp index 19c0d2b97..026fb8ca9 100644 --- a/plugins/blueprint.cpp +++ b/plugins/blueprint.cpp @@ -587,11 +587,20 @@ static string get_tile_query(df::building* b) return " "; } +// can remove once we move to C++20 +static bool ends_with(const string &str, const string &sv) +{ + if (sv.size() > str.size()) + return false; + return str.substr(str.size() - sv.size()) == sv; +} + // returns filename static string init_stream(ofstream &out, string basename, string target) { std::ostringstream out_path; - out_path << basename << "-" << target << ".csv"; + string separator = ends_with(basename, "/") ? "" : "-"; + out_path << basename << separator << target << ".csv"; string path = out_path.str(); out.open(path, ofstream::trunc); out << "#" << target << endl; diff --git a/plugins/lua/blueprint.lua b/plugins/lua/blueprint.lua index 628fb552c..bd0df0a7e 100644 --- a/plugins/lua/blueprint.lua +++ b/plugins/lua/blueprint.lua @@ -69,8 +69,8 @@ local function parse_positionals(opts, args, start_argidx) :format(args[argidx])) end argidx = argidx + 1 - -- normalize paths to forward slashes - opts.name = name:gsub(package.config:sub(1,1), "/") + -- normalize paths and remove leading slashes + opts.name = utils.normalizePath(name):gsub('^/', '') local auto_phase = true local phase = args[argidx]