From 838d0ea4dd24ff36aee6f378136d5018199487eb Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Fri, 26 Apr 2024 11:22:58 +0200 Subject: [PATCH] [cli] Create output directory. Prints a warning on error, e.g.: warning: Could not create output directory _out. Error code 17, File exists --- Applications/CLI/ogs.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index 0e28b646f44..41727f6ddba 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include "CommandLineArgumentParser.h" @@ -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; {