xtd - Reference Guide 0.2.0
path.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <cstdlib>
7 #include <random>
8 #include <regex>
9 #include <sstream>
10 #include "../core_export.h"
11 #include "../static.h"
12 #include "../ustring.h"
13 #include "file.h"
14 
15 //#include <iostream>
16 
18 namespace xtd {
20  namespace io {
32  class core_export_ path static_ {
33  public:
35 
44  template<typename char_t>
45  static char_t alt_directory_separator_char() noexcept {return static_cast<char_t>(alt_directory_separator_char());}
46 
54  static char alt_directory_separator_char() noexcept;
55 
62  template<typename char_t>
63  static char_t directory_separator_char() noexcept {
64  return static_cast<char_t>(directory_separator_char());
65  }
66 
73  static char directory_separator_char() noexcept;
74 
79  template<typename char_t>
80  static char_t path_separator() noexcept {return static_cast<char_t>(path_separator());}
81 
86  static char path_separator() noexcept;
87 
92  template<typename char_t>
93  static char_t volume_separator_char() noexcept {return static_cast<char_t>(volume_separator_char());}
94 
99  static char volume_separator_char() noexcept;
101 
103 
116  static xtd::ustring change_extension(const xtd::ustring& path, const xtd::ustring& extension);
117 
123  static xtd::ustring combine(const xtd::ustring& path1, const xtd::ustring& path2);
124 
131  template<typename type1_t, typename type2_t, typename type3_t>
132  static auto combine(type1_t path1, type2_t path2, type3_t path3) noexcept {
133  return combine(combine(path1, path2), path3);
134  }
135 
143  template<typename type1_t, typename type2_t, typename type3_t, typename type4_t>
144  static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept {
145  return combine(combine(combine(path1, path2), path3), path4);
146  }
147 
152  template<typename path_t>
153  static xtd::ustring combine(path_t paths) noexcept {
154  xtd::ustring result;
155  for (auto path : paths)
156  result = combine(result, path);
157  return result;
158  }
159 
164  static xtd::ustring combine(const std::initializer_list<xtd::ustring>& paths) noexcept;
165 
170  static xtd::ustring get_directory_name(const xtd::ustring& path);
171 
176  static xtd::ustring get_extension(const xtd::ustring& path);
177 
182  static xtd::ustring get_file_name(const xtd::ustring& path);
183 
184  static xtd::ustring get_file_name_without_extension(const xtd::ustring& path);
185 
189  static xtd::ustring get_full_path(const xtd::ustring& path);
190 
194  template<typename char_t>
195  static std::vector<char_t> get_invalid_path_chars() noexcept {return {34, 60, 62, 124, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0};}
196 
200  static std::vector<char> get_invalid_path_chars() noexcept;
201 
207  static xtd::ustring get_path_root(const xtd::ustring& path);
208 
212  static xtd::ustring get_random_file_name();
213 
219  static xtd::ustring get_temp_file_name();
220 
228  static xtd::ustring get_temp_path() noexcept;
229 
235  static bool has_extension(const xtd::ustring& path);
236 
242  static bool is_path_rooted(const xtd::ustring& path);
243 
244  private:
245  static int __get_index_path_rooted(const xtd::ustring& path);
246  static bool __is_drive(const xtd::ustring& path) noexcept;
247  };
248  }
249 }
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:38
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
static std::vector< char_t > get_invalid_path_chars() noexcept
Gets an array containing the characters that are not allowed in path names.
Definition: path.h:195
Contains xtd::io::file class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept
Combines four path strings.
Definition: path.h:144
static char_t directory_separator_char() noexcept
Provides a platform-specific character used to separate directory levels in a path string that reflec...
Definition: path.h:63
static char_t path_separator() noexcept
A platform-specific separator character used to separate path strings in environment variables...
Definition: path.h:80
Performs operations on std::basic_string instances that contain file or directory path information...
Definition: path.h:32
static char_t volume_separator_char() noexcept
Provides a platform-specific volume separator character.
Definition: path.h:93
static char_t alt_directory_separator_char() noexcept
Provides a platform-specific alternate character used to separate directory levels in a path string t...
Definition: path.h:45
static auto combine(type1_t path1, type2_t path2, type3_t path3) noexcept
Combines three path strings.
Definition: path.h:132
static xtd::ustring combine(path_t paths) noexcept
Combines path strings array.
Definition: path.h:153