Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model directory is created if not existing and a runtime exception is… #5

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"${workspaceFolder}/**",
"/usr/include/c++/14/",
"/usr/include/linux/",
"/usr/include/",
"/home/GHo/Documents/Code/NebulOuS/Solver/",
"/home/GHo/Documents/Code/Theron++/",
"/home/GHo/Documents/Code/CxxOpts/include/",
Expand All @@ -31,6 +32,7 @@
"/home/GHo/Documents/Code/Theron++/",
"/home/GHo/Documents/Code/CxxOpts/include/",
"/opt/AMPL/amplapi/include/",
"/usr/include/",
"/usr/include/c++/14/",
"/usr/include/linux/"
],
Expand Down
3 changes: 3 additions & 0 deletions AMPLSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ std::string AMPLSolver::SaveFile( std::string_view TheName,

if( TheFile.is_open() )
{
Theron::ConsoleOutput Output;
Output << "AMPL Solver saving the file: " << TheFileName << std::endl;

TheFile << TheContent;
TheFile.close();
return TheFileName;
Expand Down
18 changes: 17 additions & 1 deletion SolverComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,24 @@ int main( int NumberOfCLIOptions, char ** CLIOptionStrings )

std::filesystem::path ModelDirectory( CLIValues["ModelDir"].as<std::string>() );

if( ModelDirectory.empty() || !std::filesystem::exists( ModelDirectory ) )
if( ModelDirectory.empty() )
ModelDirectory = std::filesystem::temp_directory_path();
else if ( !std::filesystem::exists( ModelDirectory ) )
{
if( !std::filesystem::create_directory( ModelDirectory ) )
{
std::source_location Location = std::source_location::current();
std::ostringstream ErrorMessage;

ErrorMessage << "[" << Location.file_name() << " at line "
<< Location.line() << "in function "
<< Location.function_name() <<"] "
<< "The requested model directory " << ModelDirectory
<< " does not exist and cannot be created";

throw std::runtime_error( ErrorMessage.str() );
}
}

// --------------------------------------------------------------------------
// AMQ options
Expand Down