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

Remove Boost-Filesystem and replace it with the std::filesystem #1642

Merged
merged 17 commits into from
Jan 9, 2024

Conversation

cbentejac
Copy link
Contributor

@cbentejac cbentejac commented Jan 8, 2024

Description

This PR replaces all the calls to boost::filesystem by calls to std::filesystem when possible, and alternatives when it is not. Since C++17, most of the functions in boost::filesystem are part of the standard "filesystem" library.

As a consequence, Boost-Filesystem is removed from the list of dependencies.

Implementation remarks

  • boost::filesystem::unique_path() has not been ported to the std::filesystem because of security reasons (https://stackoverflow.com/questions/43316527/what-is-the-c17-equivalent-to-boostfilesystemunique-path): we replaced any call to it with a specific utilitary function, generateUniqueFilename(), which mimics unique_path().
  • boost::filesystem::last_write_time(path) returned an std::time_t whereas std::filesystem::last_write_time(path) returns an std::filesystem::file_time_type, which cannot be directly cast to an std::time_t. To address this issue, we use a utilitary function to get the last write time by ourselves, based on OIIO's function for that specific operation.

@cbentejac cbentejac added this to the 3.3.0 milestone Jan 8, 2024
@cbentejac cbentejac self-assigned this Jan 8, 2024
@cbentejac cbentejac force-pushed the dev/filesystemPath branch 2 times, most recently from 6d20ed2 to 0c91db3 Compare January 8, 2024 12:08
@cbentejac cbentejac marked this pull request as draft January 8, 2024 15:45
This commit removes Boost::filesystem from all the executables. For
executables that included modules that are still using Boost::filesystem,
the specific included files in these modules have been modified to also
replace Boost::filesystem calls by std::filesystem ones.
@cbentejac cbentejac force-pushed the dev/filesystemPath branch 2 times, most recently from 471e822 to 533fe78 Compare January 8, 2024 16:57
@cbentejac cbentejac marked this pull request as ready for review January 8, 2024 18:21
This is meant to be used as a replacement for
`boost::filesystem::unique_path()` as it is not part of `std::filesystem`
yet because of a potential exploit (https://stackoverflow.com/a/43318175).
@fabiencastan fabiencastan merged commit f22a026 into develop Jan 9, 2024
4 checks passed
@fabiencastan fabiencastan deleted the dev/filesystemPath branch January 9, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants