path_help.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_core.h"
00035 #include <vector>
00036 
00040 class CL_API_CORE CL_PathHelp
00041 {
00044 
00045 public:
00047         enum PathType
00048         {
00050                 path_type_file,
00051 
00053                 path_type_virtual
00054         };
00055 
00102         static CL_String make_absolute(
00103                 const CL_String &base_path,
00104                 const CL_String &relative_path,
00105                 PathType path_type = path_type_file);
00106 
00126         static CL_String make_relative(
00127                 const CL_String &base_path,
00128                 const CL_String &absolute_path,
00129                 PathType path_type = path_type_file);
00130 
00136         static bool is_absolute(
00137                 const CL_String &path,
00138                 PathType path_type = path_type_file);
00139 
00145         static bool is_relative(
00146                 const CL_String &path,
00147                 PathType path_type = path_type_file);
00148 
00158         static CL_String normalize(
00159                 const CL_String &path,
00160                 PathType path_type = path_type_file);
00161 
00169         static CL_String add_trailing_slash(
00170                 const CL_String &path,
00171                 PathType path_type = path_type_file);
00172 
00179         static CL_String remove_trailing_slash(
00180                 const CL_String &path);
00181 
00188         static CL_String get_location(
00189                 const CL_String &fullname,
00190                 PathType path_type = path_type_file);
00191 
00199         static CL_String get_basepath(
00200                 const CL_String &fullname,
00201                 PathType path_type = path_type_file);
00202 
00204 
00207         static std::vector<CL_String> split_basepath(
00208                 const CL_String &fullname,
00209                 PathType path_type = path_type_file);
00210 
00212 
00215         static CL_String get_fullpath(
00216                 const CL_String &fullname,
00217                 PathType path_type = path_type_file);
00218 
00220 
00223         static CL_String get_filename(
00224                 const CL_String &fullname,
00225                 PathType path_type = path_type_file);
00226 
00228 
00231         static CL_String get_basename(
00232                 const CL_String &fullname,
00233                 PathType path_type = path_type_file);
00234 
00236 
00240         static CL_String get_extension(
00241                 const CL_String &fullname,
00242                 PathType path_type = path_type_file);
00243 
00245 
00249         static CL_String get_fullname(
00250                 const CL_String &fullpath,
00251                 const CL_String &filename,
00252                 PathType path_type = path_type_file);
00253 
00255 
00260         static CL_String get_fullname(
00261                 const CL_String &fullpath,
00262                 const CL_String &filename,
00263                 const CL_String &extension,
00264                 PathType path_type = path_type_file);
00265 
00267 
00273         static CL_String get_fullname(
00274                 const CL_String &location,
00275                 const CL_String &basepath,
00276                 const CL_String &filename,
00277                 const CL_String &extension,
00278                 PathType path_type = path_type_file);
00279 
00284         static CL_String combine(const CL_String &part1, const CL_String &part2, PathType path_type = path_type_file);
00286 };
00287