xtd 0.2.0
path.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "file.hpp"
6#include "../array.hpp"
7#include "../core_export.hpp"
8#include "../static.hpp"
9#include "../string.hpp"
10#include <algorithm>
11#include <cstdlib>
12#include <random>
13#include <regex>
14#include <sstream>
15
16//#include <iostream>
17
19namespace xtd {
21 namespace io {
38 public:
40
49 template<class char_t>
50 static char_t alt_directory_separator_char() noexcept {return static_cast<char_t>(alt_directory_separator_char());}
51
59 static char alt_directory_separator_char() noexcept;
60
67 template<class char_t>
68 static char_t directory_separator_char() noexcept {
69 return static_cast<char_t>(directory_separator_char());
70 }
71
78 static char directory_separator_char() noexcept;
79
84 template<class char_t>
85 static char_t path_separator() noexcept {return static_cast<char_t>(path_separator());}
86
91 static char path_separator() noexcept;
92
97 template<class char_t>
98 static char_t volume_separator_char() noexcept {return static_cast<char_t>(volume_separator_char());}
99
104 static char volume_separator_char() noexcept;
106
108
121 static xtd::string change_extension(const xtd::string& path, const xtd::string& extension);
122
128 static xtd::string combine(const xtd::string& path1, const xtd::string& path2);
129
136 template<class type1_t, class type2_t, class type3_t>
137 static auto combine(type1_t path1, type2_t path2, type3_t path3) noexcept {
138 return combine(combine(path1, path2), path3);
139 }
140
148 template<class type1_t, class type2_t, class type3_t, class type4_t>
149 static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept {
150 return combine(combine(combine(path1, path2), path3), path4);
151 }
152
157 template<class path_t>
158 static xtd::string combine(path_t paths) noexcept {
159 xtd::string result;
160 std::for_each(paths.begin(), paths.end(), [&](auto path) {result = combine(result, path);});
161 return result;
162 }
163
168 static xtd::string combine(const std::initializer_list<xtd::string>& paths) noexcept;
169
175
181
187
193
198
202 template<class char_t>
203 static xtd::array<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};}
204
209
215 static xtd::string get_path_root(const xtd::string& path);
216
221 static xtd::string get_random_file_name();
227 static xtd::string get_random_file_name(size_t name_length);
233 static xtd::string get_random_file_name(size_t name_size, size_t extension_size);
234
240 static xtd::string get_temp_file_name();
241
249 static xtd::string get_temp_path() noexcept;
250
256 static bool has_extension(const xtd::string& path);
257
263 static bool is_path_rooted(const xtd::string& path);
265
266 private:
267 static int32 __get_index_path_rooted(const xtd::string& path);
268 static bool __is_drive(const xtd::string& path) noexcept;
269 };
270 }
271}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Represents text as a sequence of character units.
Definition basic_string.hpp:71
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.hpp:37
static char_t volume_separator_char() noexcept
Provides a platform-specific volume separator character.
Definition path.hpp:98
static xtd::array< char > get_invalid_path_chars() noexcept
Gets an array containing the characters that are not allowed in path names.
static char path_separator() noexcept
A platform-specific separator character used to separate path strings in environment variables.
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.hpp:50
static xtd::string get_full_path(const xtd::string &path)
Returns the absolute path for the specified path string.
static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept
Combines four path strings.
Definition path.hpp:149
static char volume_separator_char() noexcept
Provides a platform-specific volume separator character.
static xtd::array< char_t > get_invalid_path_chars() noexcept
Gets an array containing the characters that are not allowed in path names.
Definition path.hpp:203
static xtd::string get_extension(const xtd::string &path)
Returns the extension of the specified path string.
static xtd::string get_directory_name(const xtd::string &path)
Returns the directory information for the specified path string.
static xtd::string get_file_name(const xtd::string &path)
Returns the file name and extension of the specified path string.
static xtd::string combine(path_t paths) noexcept
Combines path strings array.
Definition path.hpp:158
static xtd::string combine(const std::initializer_list< xtd::string > &paths) noexcept
Combines path strings array.
static char alt_directory_separator_char() noexcept
Provides a platform-specific alternate character used to separate directory levels in a path string t...
static xtd::string get_file_name_without_extension(const xtd::string &path)
Returns the file name of the specified path string without the extension.
static char_t path_separator() noexcept
A platform-specific separator character used to separate path strings in environment variables.
Definition path.hpp:85
static char directory_separator_char() noexcept
Provides a platform-specific character used to separate directory levels in a path string that reflec...
Contains xtd::io::file class.
@ io
I/O erreror occurs.
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10