-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add base::get_absolute_path_from_relative() function #119
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
// If the first element is empty, it means that the relative | ||
// file name starts with a separator and it also means that | ||
// it's an absolute address. | ||
if (relativeParts.size() >= 1 && relativeParts[0] == "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
if (relativeParts.size() >= 1 && relativeParts[0] == "") | |
if (!relativeParts.empty() && relativeParts[0] == "") |
Additional context
/usr/include/c++/13/bits/stl_vector.h:1087: method 'vector'::empty() defined here
empty() const _GLIBCXX_NOEXCEPT
^
// If the first element is empty, it means that the relative | ||
// file name starts with a separator and it also means that | ||
// it's an absolute address. | ||
if (relativeParts.size() >= 1 && relativeParts[0] == "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
if (relativeParts.size() >= 1 && relativeParts[0] == "") | |
if (relativeParts.size() >= 1 && relativeParts[0].empty()) |
Additional context
/usr/include/c++/13/bits/basic_string.h:1219: method 'basic_string'::empty() defined here
empty() const _GLIBCXX_NOEXCEPT
^
This addition is part of the solution for aseprite/aseprite#4851 which was a bug introduced in aseprite/asseprite#4389.
2d968fc
to
2ef8e31
Compare
Hi @Gasparoken, just in case, is possible that |
|
It should work as a path normalizer if the given path is an absolute path; you can check out the tests: Lines 246 to 250 in c84b89b
So you should be able to use something like |
That's great! However, I found that EXPECT_EQ("/user/file", get_absolute_path("/user/name/path/../../file")); I'll adopt this function to resolve aseprite/aseprite#4851, but I will need to fix the indicated bug first. |
I'm closing this and will take the |
Part of aseprite/aseprite#4851
It's wanted to reconstruct the absolute path starting from the relative/absolute filename in the filename entry of 'Export As' dialog.