Take std::filesystem::path where opm-common opens a file - #5345
Draft
GitPaean wants to merge 3 commits into
Draft
Conversation
GitPaean
commented
Sep 6, 2026
Member
- Takes std::filesystem::path where opm-common opens a file — the EclIO readers and writers, Parser::parseFile(), and the keyword generator's file helpers — so a caller holding a path passes it as is. std::string still converts implicitly: no call site changes, and every consumer in opm-common, opm-grid and opm-simulators builds unchanged.
- Removes the conversions the library was doing to itself (EclFile(rstFile.string()), EclOutput(smryDataFile.generic_string(), …), EInit(initFileName.generic_string())) and retires the parser's dataFileName[0] == '/' in favour of has_root_directory(), the same test expressed on the path rather than on its first byte.
- No functional change: the names simply travel as the type the standard library opens files with, and nothing decides anything by inspecting their characters any more; the full opm-common test suite passes as before.
A path converts implicitly to std::string only where path::value_type is char, so a caller holding a path had to spell .string() first, and the library did the same to itself: EclFile(rstFile.string()), EclOutput(smryDataFile.generic_string(), ...) and EInit(initFileName.generic_string()). Take and store the path instead: std::string still converts implicitly, so callers are unchanged, and the streams open with the path directly. Messages that concatenated the name go through fmt with <fmt/std.h>, which prints the path quoted.
Same reason as for EclIO: a path converts implicitly to std::string only where path::value_type is char. The absolute-path test becomes has_root_directory(), the portable spelling of the former leading-'/' test, so a rooted path is kept as given wherever it is not also absolute. The deck-visible name stays a generic_string(). The Python binding keeps its std::string signature through lambdas so it does not depend on pybind11's filesystem caster.
ensurePath(), updateFile() and the write_file() helpers take the path their callers already build, instead of receiving it as std::string and converting back. The update*() entry points keep std::string: they join the pieces CMake passes by plain concatenation.
Member
Author
|
jenkins build this please |
Member
Author
akva2
reviewed
Sep 7, 2026
akva2
left a comment
Member
There was a problem hiding this comment.
Makes sense to me. First commit would benefit from a split (path and fmt parts)
Member
|
I concur with @akva2: Taking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.