path_help.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 #include "../api_core.h"
33 #include <vector>
34 
35 namespace clan
36 {
39 
41 class CL_API_CORE PathHelp
42 {
45 
46 public:
48  enum PathType
49  {
52 
54  path_type_virtual
55  };
56 
103  static std::string make_absolute(
104  const std::string &base_path,
105  const std::string &relative_path,
106  PathType path_type = path_type_file);
107 
127  static std::string make_relative(
128  const std::string &base_path,
129  const std::string &absolute_path,
130  PathType path_type = path_type_file);
131 
137  static bool is_absolute(
138  const std::string &path,
139  PathType path_type = path_type_file);
140 
146  static bool is_relative(
147  const std::string &path,
148  PathType path_type = path_type_file);
149 
159  static std::string normalize(
160  const std::string &path,
161  PathType path_type = path_type_file);
162 
170  static std::string add_trailing_slash(
171  const std::string &path,
172  PathType path_type = path_type_file);
173 
180  static std::string remove_trailing_slash(
181  const std::string &path);
182 
189  static std::string get_location(
190  const std::string &fullname,
191  PathType path_type = path_type_file);
192 
200  static std::string get_basepath(
201  const std::string &fullname,
202  PathType path_type = path_type_file);
203 
205 
208  static std::vector<std::string> split_basepath(
209  const std::string &fullname,
210  PathType path_type = path_type_file);
211 
213 
216  static std::string get_fullpath(
217  const std::string &fullname,
218  PathType path_type = path_type_file);
219 
221 
224  static std::string get_filename(
225  const std::string &fullname,
226  PathType path_type = path_type_file);
227 
229 
232  static std::string get_basename(
233  const std::string &fullname,
234  PathType path_type = path_type_file);
235 
237 
241  static std::string get_extension(
242  const std::string &fullname,
243  PathType path_type = path_type_file);
244 
246 
250  static std::string get_fullname(
251  const std::string &fullpath,
252  const std::string &filename,
253  PathType path_type = path_type_file);
254 
256 
261  static std::string get_fullname(
262  const std::string &fullpath,
263  const std::string &filename,
264  const std::string &extension,
265  PathType path_type = path_type_file);
266 
268 
274  static std::string get_fullname(
275  const std::string &location,
276  const std::string &basepath,
277  const std::string &filename,
278  const std::string &extension,
279  PathType path_type = path_type_file);
280 
285  static std::string combine(const std::string &part1, const std::string &part2, PathType path_type = path_type_file);
287 };
288 
289 }
290 
PathType
Path types.
Definition: path_help.h:48
Native file system path. (On windows, '/' are turned into '\'. On linux, '\' are turned into '/') ...
Definition: path_help.h:51
Path helper functions.
Definition: path_help.h:41