xtd 0.2.0
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1
4#pragma once
5#include "file.h"
6#include "../core_export.h"
7#include "../static.h"
8#include "../string.h"
9#include <algorithm>
10#include <cstdlib>
11#include <random>
12#include <regex>
13#include <sstream>
14
15//#include <iostream>
16
18namespace xtd {
20 namespace io {
37 public:
39
48 template<typename char_t>
49 static char_t alt_directory_separator_char() noexcept {return static_cast<char_t>(alt_directory_separator_char());}
50
58 static char alt_directory_separator_char() noexcept;
59
66 template<typename char_t>
67 static char_t directory_separator_char() noexcept {
68 return static_cast<char_t>(directory_separator_char());
69 }
70
77 static char directory_separator_char() noexcept;
78
83 template<typename char_t>
84 static char_t path_separator() noexcept {return static_cast<char_t>(path_separator());}
85
90 static char path_separator() noexcept;
91
96 template<typename char_t>
97 static char_t volume_separator_char() noexcept {return static_cast<char_t>(volume_separator_char());}
98
103 static char volume_separator_char() noexcept;
105
107
120 static xtd::string change_extension(const xtd::string& path, const xtd::string& extension);
121
127 static xtd::string combine(const xtd::string& path1, const xtd::string& path2);
128
135 template<typename type1_t, typename type2_t, typename type3_t>
136 static auto combine(type1_t path1, type2_t path2, type3_t path3) noexcept {
137 return combine(combine(path1, path2), path3);
138 }
139
147 template<typename type1_t, typename type2_t, typename type3_t, typename type4_t>
148 static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept {
149 return combine(combine(combine(path1, path2), path3), path4);
150 }
151
156 template<typename path_t>
157 static xtd::string combine(path_t paths) noexcept {
158 xtd::string result;
159 std::for_each(paths.begin(), paths.end(), [&](auto path) {result = combine(result, path);});
160 return result;
161 }
162
167 static xtd::string combine(const std::initializer_list<xtd::string>& paths) noexcept;
168
174
180
186
192
197
201 template<typename char_t>
202 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};}
203
207 static std::vector<char> get_invalid_path_chars() noexcept;
208
214 static xtd::string get_path_root(const xtd::string& path);
215
220 static xtd::string get_random_file_name();
226 static xtd::string get_random_file_name(size_t name_length);
232 static xtd::string get_random_file_name(size_t name_size, size_t extension_size);
233
239 static xtd::string get_temp_file_name();
240
248 static xtd::string get_temp_path() noexcept;
249
255 static bool has_extension(const xtd::string& path);
256
262 static bool is_path_rooted(const xtd::string& path);
264
265 private:
266 static int32 __get_index_path_rooted(const xtd::string& path);
267 static bool __is_drive(const xtd::string& path) noexcept;
268 };
269 }
270}
Represents text as a sequence of character units.
Definition basic_string.h:79
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.h:36
static char_t volume_separator_char() noexcept
Provides a platform-specific volume separator character.
Definition path.h:97
static char path_separator() noexcept
A platform-specific separator character used to separate path strings in environment variables.
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:202
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:49
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.h:148
static char volume_separator_char() noexcept
Provides a platform-specific volume separator character.
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 std::vector< char > get_invalid_path_chars() noexcept
Gets an array containing the characters that are not allowed in path names.
static xtd::string combine(path_t paths) noexcept
Combines path strings array.
Definition path.h:157
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.h:84
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.
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
#define core_export_
Define shared library export.
Definition core_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10