2022-02-11 09:07:11 +11: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
|
|
|
|
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];
|
2012-12-28 20:21:05 +00:00
|
|
|
unsigned 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
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
for (unsigned int pos = 0, sep = path.find(Config::PATH_SEP, pos); pos < size;
|
|
|
|
|
pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) {
|
2019-05-31 22:51:19 +10:00
|
|
|
if (sep == (unsigned)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);
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(cleaned, dir.c_str(), FILE_MAX);
|
2020-11-06 17:49:09 +01:00
|
|
|
BLI_path_normalize(nullptr, 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
|