Fix #136906: Crash if asset library path contains back slash on macOS
Convert all slashes to native format when initializing an asset library. This might convert slashes that are valid parts of the file name, but this just leads to an error about a not found asset library, which is better than crashing. This is a typical tradeoff when dealing with cross platform paths.
This commit is contained in:
@@ -25,6 +25,7 @@ std::string normalize_directory_path(StringRef directory)
|
||||
directory.data(),
|
||||
/* + 1 for null terminator. */
|
||||
std::min(directory.size() + 1, int64_t(sizeof(dir_normalized))));
|
||||
BLI_path_slash_native(dir_normalized);
|
||||
BLI_path_normalize_dir(dir_normalized, sizeof(dir_normalized));
|
||||
return std::string(dir_normalized);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace blender::asset_system::utils {
|
||||
|
||||
/**
|
||||
* Returns a normalized directory path with a trailing slash, and a maximum length of #PATH_MAX.
|
||||
* Slashes are not converted to native format (they probably should be though?).
|
||||
* Slashes are converted to native format.
|
||||
*/
|
||||
std::string normalize_directory_path(StringRef directory);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user