open-simulation-platform / libcosim

OSP C++ co-simulation library
https://open-simulation-platform.github.io/libcosim
Mozilla Public License 2.0
61 stars 10 forks source link

Feature/std filesystem #637

Closed markaren closed 3 years ago

markaren commented 3 years ago

This PR replaces usage of boost::filesystem with std::filesystem. In order to support gcc7, the header fs_portability is used, which falls back to std::experimental::filesystem. Thus, usage of std::filesystem should be done using the typealias cosim::filesystem

markaren commented 3 years ago

The PR fails on file locking on windows.. Don't know how to fix..

markaren commented 3 years ago

I hope this PR is welcome. No need to use boost when we got the std available. The only caveat is that we need the fallback header in order to support gcc 6 and 7. We also need to fix the file locking unit test. @kyllingstad need your expertise on that.

kyllingstad commented 3 years ago

It's very welcome, in my opinion. I'll look into the file locking issue.

kyllingstad commented 3 years ago

Hopefully, this does the trick. The file locking mechanism has an internal cache of mutexes associated with different files, and each time one tries to create a new one, it checks whether a mutex exists for the file already. Since different paths (relative vs. absolute, links, etc.) can refer to the same file, it uses filesystem::equivalent() to perform this check. But this requires that the file exists, which we previously didn't check.

ljamt commented 3 years ago

Approving @markaren's changes here. I suppose he or @ljamt should have a look at mine.

Looks good to me 👍