OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
| 3 * |
| 4 * This program is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU General Public License |
| 6 * as published by the Free Software Foundation; either version 2 |
| 7 * of the License, or (at your option) any later version. |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software Foundation, |
| 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 * |
| 18 * The Original Code is Copyright (C) 2010 Blender Foundation. |
| 19 * All rights reserved. |
| 20 * |
| 21 * The Original Code is: all of this file. |
| 22 * |
| 23 * Contributor(s): none yet. |
| 24 * |
| 25 * ***** END GPL LICENSE BLOCK ***** |
| 26 */ |
| 27 |
| 28 /** \file blender/freestyle/intern/system/StringUtils.cpp |
| 29 * \ingroup freestyle |
| 30 * \brief String utilities |
| 31 * \author Emmanuel Turquin |
| 32 * \date 20/05/2003 |
| 33 */ |
| 34 |
| 35 //soc #include <qfileinfo.h> |
| 36 |
| 37 #include "FreestyleConfig.h" |
| 38 #include "StringUtils.h" |
| 39 |
| 40 namespace StringUtils { |
| 41 |
| 42 void getPathName(const string& path, const string& base, vector<string>& pathnam
es) |
| 43 { |
| 44 string dir; |
| 45 string res; |
| 46 char cleaned[FILE_MAX]; |
| 47 unsigned size = path.size(); |
| 48 |
| 49 pathnames.push_back(base); |
| 50 |
| 51 for (unsigned int pos = 0, sep = path.find(Config::PATH_SEP, pos); |
| 52 pos < size; |
| 53 pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) |
| 54 { |
| 55 if (sep == (unsigned)string::npos) |
| 56 sep = size; |
| 57 |
| 58 dir = path.substr(pos, sep - pos); |
| 59 |
| 60 BLI_strncpy(cleaned, dir.c_str(), FILE_MAX); |
| 61 BLI_cleanup_file(NULL, cleaned); |
| 62 res = toAscii(string(cleaned)); |
| 63 |
| 64 if (!base.empty()) |
| 65 res += Config::DIR_SEP + base; |
| 66 |
| 67 pathnames.push_back(res); |
| 68 } |
| 69 } |
| 70 |
| 71 string toAscii(const string &str) |
| 72 { |
| 73 stringstream out(""); |
| 74 char s; |
| 75 |
| 76 for (unsigned int i = 0; i < str.size() ; i++) { |
| 77 s = ((char)(str.at(i) & 0x7F)); |
| 78 out << s; |
| 79 } |
| 80 |
| 81 return out.str(); |
| 82 } |
| 83 |
| 84 const char *toAscii(const char *str) |
| 85 { |
| 86 return toAscii(string(str)).c_str(); |
| 87 } |
| 88 |
| 89 } // end of namespace StringUtils |
OLD | NEW |