From 27a5f6f9bdf5624f9d1ef680dafeaefc007bf189 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 24 Jan 2017 19:54:44 +0000 Subject: [PATCH] CLI: include directory name in %-replacement. --- src/platform/climain.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/platform/climain.cpp b/src/platform/climain.cpp index f41e242..1eff1ee 100644 --- a/src/platform/climain.cpp +++ b/src/platform/climain.cpp @@ -18,10 +18,10 @@ static void ShowUsage(const std::string &cmd) { Common options: -o, --output - For an input file .slvs, replaces the '%%' symbol in - with and uses it as output file. For example, when using - --output %%-2d.png for input files a.slvs and b.slvs, output files - a-2d.png and b-2d.png will be written. + For an input file .slvs, replaces the '%%' symbol in + with and uses it as output file. For example, when using + --output %%-2d.png for input files f/a.slvs and f/b.slvs, output files + f/a-2d.png and f/b-2d.png will be written. -v, --view Selects the camera direction. can be one of "top", "bottom", "left", "right", "front", "back", or "isometric". @@ -291,7 +291,11 @@ static bool RunCommand(const std::vector args) { std::string outputFile = outputPattern; size_t replaceAt = outputFile.find('%'); if(replaceAt != std::string::npos) { - outputFile.replace(replaceAt, 1, Basename(inputFile, /*stripExtension=*/true)); + std::string outputSubst; + outputSubst = Dirname(inputFile); + outputSubst += PATH_SEP; + outputSubst += Basename(inputFile, /*stripExtension=*/true); + outputFile.replace(replaceAt, 1, outputSubst); } std::string absOutputFile = PathFromCurrentDirectory(outputFile);