Fix handling of relative paths with no directory in solvespace-cli.

Before this commit, e.g. `solvespace-cli regenerate foo.slvs`
would save a file called just `.slvs`.
pull/332/head
whitequark 2018-05-10 15:31:55 +00:00
parent c6fc0125a2
commit 2b9ffd1542
1 changed files with 5 additions and 1 deletions

View File

@ -307,7 +307,11 @@ static bool RunCommand(const std::vector<std::string> args) {
size_t replaceAt = outputFile.raw.find('%'); size_t replaceAt = outputFile.raw.find('%');
if(replaceAt != std::string::npos) { if(replaceAt != std::string::npos) {
Platform::Path outputSubst = inputFile.Parent(); Platform::Path outputSubst = inputFile.Parent();
if(outputSubst.IsEmpty()) {
outputSubst = Platform::Path::From(inputFile.FileStem());
} else {
outputSubst = outputSubst.Join(inputFile.FileStem()); outputSubst = outputSubst.Join(inputFile.FileStem());
}
outputFile.raw.replace(replaceAt, 1, outputSubst.raw); outputFile.raw.replace(replaceAt, 1, outputSubst.raw);
} }
Platform::Path absOutputFile = outputFile.Expand(/*fromCurrentDirectory=*/true); Platform::Path absOutputFile = outputFile.Expand(/*fromCurrentDirectory=*/true);