Skip to content

Commit

Permalink
Savegame Tool: Added -output option to redirect .save output to anoth…
Browse files Browse the repository at this point in the history
…er directory
  • Loading branch information
danij-deng committed Mar 20, 2014
1 parent 39bdce4 commit 41d1883
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions doomsday/tools/savegametool/src/main.cpp
Expand Up @@ -52,7 +52,8 @@ static void printUsage()
LOG_INFO("Usage: %s [options] savegame-path ...\n"
"Options:\n"
"--help, -h, -? Show usage information."
"-idKey Fallback game identity key. Used to resolve ambigous savegame formats.")
"-idKey Fallback game identity key. Used to resolve ambigous savegame formats."
"-output Redirect .save output to this directory (default is the working directory).")
<< DENG2_TEXT_APP->commandLine().at(0);
}

Expand Down Expand Up @@ -172,8 +173,8 @@ int main(int argc, char **argv)
LogBuffer::DontFlush);

// Default /output to the current working directory.
app.fileSystem().makeFolder("/output").attach(new DirectoryFeed(NativePath::workPath(),
DirectoryFeed::AllowWrite | DirectoryFeed::CreateIfMissing));
app.fileSystem().makeFolder("/output").attach(
new DirectoryFeed(NativePath::workPath(), DirectoryFeed::AllowWrite));
outputFolder().setMode(File::Write | File::Truncate);

// Print a banner.
Expand All @@ -198,6 +199,17 @@ int main(int argc, char **argv)
fallbackGameId = args.at(i + 1).strip().toLower();
i += 1;
}
// The -output option can be used to redirect .save output.
if(i + 1 < args.count() && !args.at(i).compareWithoutCase("-output"))
{
args.makeAbsolutePath(i);
delete outputFolder().detach(*outputFolder().feeds().front());
outputFolder().attach(new DirectoryFeed(NativePath(args.at(i + 1)),
DirectoryFeed::AllowWrite | DirectoryFeed::CreateIfMissing));
outputFolder().setMode(File::Write | File::Truncate);
outputFolder().populate(Folder::PopulateOnlyThisFolder);
i += 1;
}
continue;
}

Expand Down

0 comments on commit 41d1883

Please sign in to comment.