Skip to content

Commit

Permalink
Initialization file without inputPath (#8791)
Browse files Browse the repository at this point in the history
* Initialization file without inputPath

  Used when the initialization file is given via -iif
  as absolute absolute path but -inputPath is set as well.

* Fixing stuff
  • Loading branch information
AnHeuermann committed Apr 5, 2022
1 parent c72be69 commit 68f0cde
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions OMCompiler/SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -542,16 +542,32 @@ int startNonInteractiveSimulation(int argc, char**argv, DATA* data, threadData_t
init_initMethod = omc_flagValue[FLAG_IIM];
}
if(omc_flag[FLAG_IIF]) {
#if defined(__MINGW32__) || defined(_MSC_VER)
struct _stat attrib;
#else
struct stat attrib;
#endif
if (omc_flag[FLAG_INPUT_PATH]) {
const char *tmp_filename;
if (0 > GC_asprintf(&tmp_filename, "%s/%s", omc_flagValue[FLAG_INPUT_PATH], omc_flagValue[FLAG_IIF])) {
throwStreamPrint(NULL, "simulation_runtime.cpp: Error: can not allocate memory.");

if (omc_stat(omc_flagValue[FLAG_IIF], &attrib ) == 0) {
if (0 > GC_asprintf(&tmp_filename, "%s", omc_flagValue[FLAG_IIF] )) {
throwStreamPrint(NULL, "simulation_runtime.cpp: Error: can not allocate memory.");
}
}
else {
if (0 > GC_asprintf(&tmp_filename, "%s/%s", omc_flagValue[FLAG_INPUT_PATH], omc_flagValue[FLAG_IIF])) {
throwStreamPrint(NULL, "simulation_runtime.cpp: Error: can not allocate memory.");
}
}
init_file = tmp_filename;
}
else {
init_file = omc_flagValue[FLAG_IIF];
}
if (omc_stat(init_file.c_str(), &attrib ) != 0) {
throwStreamPrint(NULL, "Initialization file \"%s\" doesn't exist.", init_file.c_str());
}
}
if(omc_flag[FLAG_IIT]) {
init_time_string = omc_flagValue[FLAG_IIT];
Expand Down

0 comments on commit 68f0cde

Please sign in to comment.