Fix BLI_path_parent_dir failing on paths ending with ".."

The check for BLI_path_normalize having succeeded only checked for a
trailing "../" which isn't correct. This caused going up a directory
in the file selector to do nothing on directories ending with "..".

This also caused an empty path to expand into "../" because
BLI_path_extension_check didn't account for this case.

Resolve using BLI_path_name_at_index which extracts the last component
of the path without having to match the the surrounding slashes.
This commit is contained in:
2022-11-01 22:02:08 +11:00
parent 12f4ac1706
commit cc6f41f8a5
3 changed files with 32 additions and 5 deletions

View File

@@ -364,6 +364,8 @@ bool BLI_path_make_safe(char *path) ATTR_NONNULL(1);
*
* Replaces path with the path of its parent directory, returning true if
* it was able to find a parent directory within the path.
*
* On success, the resulting path will always have a trailing slash.
*/
bool BLI_path_parent_dir(char *path) ATTR_NONNULL();
/**