Blender  V2.93
StringUtils.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 // soc #include <qfileinfo.h>
23 
24 #include "StringUtils.h"
25 #include "FreestyleConfig.h"
26 
28 
29 void getPathName(const string &path, const string &base, vector<string> &pathnames)
30 {
31  string dir;
32  string res;
33  char cleaned[FILE_MAX];
34  unsigned size = path.size();
35 
36  pathnames.push_back(base);
37 
38  for (unsigned int pos = 0, sep = path.find(Config::PATH_SEP, pos); pos < size;
39  pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) {
40  if (sep == (unsigned)string::npos) {
41  sep = size;
42  }
43 
44  dir = path.substr(pos, sep - pos);
45 
46  BLI_strncpy(cleaned, dir.c_str(), FILE_MAX);
47  BLI_path_normalize(nullptr, cleaned);
48  res = string(cleaned);
49 
50  if (!base.empty()) {
51  res += Config::DIR_SEP + base;
52  }
53 
54  pathnames.push_back(res);
55  }
56 }
57 
58 } // namespace Freestyle::StringUtils
#define FILE_MAX
void BLI_path_normalize(const char *relabase, char *path) ATTR_NONNULL(2)
Definition: path_util.c:173
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
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:29