Skip to content

Commit

Permalink
Add mingw workaround to setWorkingDirectory (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Jul 9, 2021
1 parent a734342 commit f015277
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/OMSimulatorLib/Scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,17 @@ oms_status_enu_t oms::Scope::setWorkingDirectory(const std::string& newWorkingDi
{
try
{
if (!filesystem::is_directory(newWorkingDir))
return logError("Set working directory to \"" + newWorkingDir + "\" failed");
std::string newWorkingDirWorkaround = newWorkingDir;
#if defined(__MINGW32__)
// create_directory() behaves different with clang 11 than gcc for path with trailing "/"
if('/' == newWorkingDirWorkaround.back()) {
newWorkingDirWorkaround.pop_back();
}
#endif
if (!filesystem::is_directory(newWorkingDirWorkaround))
return logError("Set working directory to \"" + newWorkingDirWorkaround + "\" failed");

filesystem::path path(newWorkingDir.c_str());
filesystem::path path(newWorkingDirWorkaround.c_str());
path = oms_canonical(path);

filesystem::current_path(path);
Expand Down

0 comments on commit f015277

Please sign in to comment.