This repository was archived by the owner on Dec 22, 2024. It is now read-only.
Use std::filesystem::weakly_canonical() to avoid filesyste_error #62
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.
This PR fixes a bug about path normalization.
Bug behavior
This bug occurs when the users specify absolute path but it actually does not exist. When
mimium
command is passed such a path, the command fails like this:Additionally, if a path specified exists,
mimium
command normalizes the path and then continues its process.I found this behavior in development of mimium mapckage manager.
The cause of this bug
mimium
does path normalization at first of its process but it has not done correctly.The path normalization has done at this point:
mimium/src/frontend/genericapp.cpp
Line 64 in 263f357
According to this page, the function
std::filesystem::canonical()
throwsfilesystem_error
when the path does not exist. That page also says that the function does fully existence check for all path elements.How to fix
That page also says
std::filesystem::weakly_canonical()
does the path normalization partially. It means that the specified path so the path entirely may not exist.If using
weakly_canonical()
instead ofcanonical()
, themimium
command successfully normalizes at the point of the source code, checks input path existence then handles by the situation by itself, like this:So, in this PR's case, using
weakly_canonical()
is better.