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.
32 lines
950 B
C++
32 lines
950 B
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup asset_system
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_string_ref.hh"
|
|
|
|
namespace blender::asset_system::utils {
|
|
|
|
/**
|
|
* Returns a normalized directory path with a trailing slash, and a maximum length of #PATH_MAX.
|
|
* Slashes are converted to native format.
|
|
*/
|
|
std::string normalize_directory_path(StringRef directory);
|
|
|
|
/**
|
|
* Normalize the given `path` (remove 'parent directory' and double-slashes element etc., and
|
|
* convert to native path separators).
|
|
*
|
|
* If \a max_len is not #StringRef::not_found (default value), only the first part of the given
|
|
* string up to the given length is processed, the rest remains unchanged. Needed to avoid
|
|
* modifying ID name part of linked library paths.
|
|
*/
|
|
std::string normalize_path(StringRefNull path, int64_t max_len = StringRef::not_found);
|
|
|
|
} // namespace blender::asset_system::utils
|