Skip to content

Commit

Permalink
[cli] Create output directory.
Browse files Browse the repository at this point in the history
Prints a warning on error, e.g.:

warning: Could not create output directory _out. Error code 17, File exists
  • Loading branch information
bilke authored and TomFischer committed Apr 30, 2024
1 parent cb03f90 commit 838d0ea
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Applications/CLI/ogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <tclap/CmdLine.h>

#include <chrono>
#include <filesystem>
#include <sstream>

#include "CommandLineArgumentParser.h"
Expand Down Expand Up @@ -64,6 +65,20 @@ int main(int argc, char* argv[])
INFO("This is OpenGeoSys-6 version {:s}.",
GitInfoLib::GitInfo::ogs_version);

{
std::error_code mkdir_err;
if (std::filesystem::create_directories(cli_arg.outdir, mkdir_err))
{
INFO("Output directory {:s} created.", cli_arg.outdir);
}
else if (mkdir_err.value() != 0)
{
WARN(
"Could not create output directory {:s}. Error code {:d}, {:s}",
cli_arg.outdir, mkdir_err.value(), mkdir_err.message());
}
}

BaseLib::RunTime run_time;

{
Expand Down

0 comments on commit 838d0ea

Please sign in to comment.