2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008-2023 Blender Authors
|
2023-06-14 23:30:43 +10:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief String utilities
|
2012-12-28 20:21:05 +00:00
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-04-30 17:50:57 +10:00
|
|
|
// soc #include <qfileinfo.h>
|
2012-12-28 20:21:05 +00:00
|
|
|
|
2008-04-30 15:41:54 +00:00
|
|
|
#include "StringUtils.h"
|
2020-04-21 12:39:12 +02:00
|
|
|
#include "FreestyleConfig.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2022-10-26 18:58:04 +02:00
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
|
2020-11-07 18:17:12 +05:30
|
|
|
namespace Freestyle::StringUtils {
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
void getPathName(const string &path, const string &base, vector<string> &pathnames)
|
|
|
|
|
{
|
|
|
|
|
string dir;
|
2008-05-26 19:52:55 +00:00
|
|
|
string res;
|
|
|
|
|
char cleaned[FILE_MAX];
|
2022-09-26 10:04:44 +10:00
|
|
|
uint size = path.size();
|
2008-05-09 23:06:28 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
pathnames.push_back(base);
|
2008-05-26 19:52:55 +00:00
|
|
|
|
2022-09-25 17:04:52 +10:00
|
|
|
for (uint pos = 0, sep = path.find(Config::PATH_SEP, pos); pos < size;
|
2012-12-28 20:21:05 +00:00
|
|
|
pos = sep + 1, sep = path.find(Config::PATH_SEP, pos))
|
|
|
|
|
{
|
2022-09-26 10:04:44 +10:00
|
|
|
if (sep == uint(string::npos)) {
|
2008-05-26 19:52:55 +00:00
|
|
|
sep = size;
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2012-12-28 20:21:05 +00:00
|
|
|
|
2008-05-26 19:52:55 +00:00
|
|
|
dir = path.substr(pos, sep - pos);
|
|
|
|
|
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(cleaned, dir.c_str());
|
2023-04-24 11:31:31 +10:00
|
|
|
BLI_path_normalize(cleaned);
|
2013-05-01 13:34:56 +00:00
|
|
|
res = string(cleaned);
|
2012-12-28 20:21:05 +00:00
|
|
|
|
2019-05-31 22:51:19 +10:00
|
|
|
if (!base.empty()) {
|
2008-05-26 19:52:55 +00:00
|
|
|
res += Config::DIR_SEP + base;
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2012-12-28 20:21:05 +00:00
|
|
|
|
2008-05-26 19:52:55 +00:00
|
|
|
pathnames.push_back(res);
|
2008-05-11 20:28:47 +00:00
|
|
|
}
|
2012-12-28 20:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-07 18:17:12 +05:30
|
|
|
} // namespace Freestyle::StringUtils
|