No user visible changes expected. If an asset library is located on disk, store the path to it in the asset library data. This is called the "root path" now. With this we can construct an asset identifier, which is introduced in the following commit.
31 lines
720 B
C++
31 lines
720 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup asset_system
|
|
*/
|
|
|
|
#include "BLI_fileops.h"
|
|
#include "BLI_path_util.h"
|
|
#include "BLI_string.h"
|
|
|
|
#include "utils.hh"
|
|
|
|
namespace blender::asset_system::utils {
|
|
|
|
std::string normalize_directory_path(StringRef directory)
|
|
{
|
|
if (directory.is_empty()) {
|
|
return "";
|
|
}
|
|
|
|
char dir_normalized[PATH_MAX];
|
|
BLI_strncpy(dir_normalized,
|
|
directory.data(),
|
|
/* + 1 for null terminator. */
|
|
std::min(directory.size() + 1, int64_t(sizeof(dir_normalized))));
|
|
BLI_path_normalize_dir(nullptr, dir_normalized, sizeof(dir_normalized));
|
|
return std::string(dir_normalized);
|
|
}
|
|
|
|
} // namespace blender::asset_system::utils
|