Blender  V3.3
StringUtils.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 // soc #include <qfileinfo.h>
9 
10 #include "StringUtils.h"
11 #include "FreestyleConfig.h"
12 
14 
15 void getPathName(const string &path, const string &base, vector<string> &pathnames)
16 {
17  string dir;
18  string res;
19  char cleaned[FILE_MAX];
20  unsigned size = path.size();
21 
22  pathnames.push_back(base);
23 
24  for (unsigned int pos = 0, sep = path.find(Config::PATH_SEP, pos); pos < size;
25  pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) {
26  if (sep == (unsigned)string::npos) {
27  sep = size;
28  }
29 
30  dir = path.substr(pos, sep - pos);
31 
32  BLI_strncpy(cleaned, dir.c_str(), FILE_MAX);
33  BLI_path_normalize(nullptr, cleaned);
34  res = string(cleaned);
35 
36  if (!base.empty()) {
37  res += Config::DIR_SEP + base;
38  }
39 
40  pathnames.push_back(res);
41  }
42 }
43 
44 } // namespace Freestyle::StringUtils
#define FILE_MAX
void BLI_path_normalize(const char *relabase, char *path) ATTR_NONNULL(2)
Definition: path_util.c:131
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
Configuration definitions.
String utilities.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
uint pos
static const string DIR_SEP("/")
static const string PATH_SEP(":")
void getPathName(const string &path, const string &base, vector< string > &pathnames)
Definition: StringUtils.cpp:15