A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.
This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.
Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.
Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:
https://reuse.software/faq/
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* 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(dir_normalized, sizeof(dir_normalized));
|
|
return std::string(dir_normalized);
|
|
}
|
|
|
|
std::string normalize_path(StringRefNull path, int64_t max_len)
|
|
{
|
|
const int64_t len = (max_len == StringRef::not_found) ? path.size() :
|
|
std::min(max_len, path.size());
|
|
|
|
char *buf = BLI_strdupn(path.c_str(), len);
|
|
BLI_path_slash_native(buf);
|
|
BLI_path_normalize(buf);
|
|
|
|
std::string normalized_path = buf;
|
|
MEM_freeN(buf);
|
|
|
|
if (len != path.size()) {
|
|
normalized_path = normalized_path + path.substr(len);
|
|
}
|
|
|
|
return normalized_path;
|
|
}
|
|
|
|
} // namespace blender::asset_system::utils
|