xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1
4#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"
14//#include "drive_into.h"
15#include "file.h"
16
17//#include <iostream>
18
20namespace xtd {
22 namespace io {
30 public:
38 template<typename char_t>
39 static char_t alt_directory_separator_char() noexcept {return static_cast<char_t>('/');}
40
48 static char alt_directory_separator_char() noexcept;
49
61 static xtd::ustring change_extension(const xtd::ustring& path, const xtd::ustring& extension);
62
68 static xtd::ustring combine(const xtd::ustring& path1, const xtd::ustring& path2);
69
76 template<typename type1_t, typename type2_t, typename type3_t>
77 static auto combine(type1_t path1, type2_t path2, type3_t path3) noexcept {
78 return combine(combine(path1, path2), path3);
79 }
80
88 template<typename type1_t, typename type2_t, typename type3_t, typename type4_t>
89 static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept {
90 return combine(combine(combine(path1, path2), path3), path4);
91 }
92
97 template<typename path_t>
98 static xtd::ustring combine(path_t paths) noexcept {
99 xtd::ustring result;
100 for (auto path : paths)
101 result = combine(result, path);
102 return result;
103 }
104
109 static xtd::ustring combine(const std::initializer_list<xtd::ustring>& paths) noexcept;
110
117 template<typename char_t>
118 static char_t directory_separator_char() noexcept {
119 return __is_windows_os() ? static_cast<char_t>('\\') : static_cast<char_t>('/');
120 }
121
128 static char directory_separator_char() noexcept;
129
134 static xtd::ustring get_directory_name(const xtd::ustring& path);
135
140 static xtd::ustring get_extension(const xtd::ustring& path);
141
146 static xtd::ustring get_file_name(const xtd::ustring& path);
147
148 static xtd::ustring get_file_name_without_extension(const xtd::ustring& path);
149
153 static xtd::ustring get_full_path(const xtd::ustring& path);
154
158 template<typename char_t>
159 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};}
160
164 static std::vector<char> get_invalid_path_chars() noexcept;
165
171 static xtd::ustring get_path_root(const xtd::ustring& path);
172
176 static xtd::ustring get_random_file_name();
177
183 static xtd::ustring get_temp_file_name();
184
192 static xtd::ustring get_temp_path() noexcept;
193
199 static bool has_extension(const xtd::ustring& path);
200
206 static bool is_path_rooted(const xtd::ustring& path);
207
212 template<typename char_t>
213 static char_t path_separator() noexcept {return static_cast<char_t>(':');}
214
219 static char path_separator() noexcept;
220
225 template<typename char_t>
226 static char_t volume_separator_char() noexcept {return __is_windows_os() ? ':' : '/';}
227
232 static char volume_separator_char() noexcept;
233
234 private:
235 static int __get_index_path_rooted(const xtd::ustring& path);
236 static bool __is_windows_os() noexcept;
237 static bool __is_drive(const xtd::ustring& path) noexcept;
238 };
239 }
240}
Performs operations on std::basic_string instances that contain file or directory path information....
Definition: path.h:29
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:118
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.h:39
static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept
Combines four path strings.
Definition: path.h:89
static char volume_separator_char() noexcept
Provides a platform-specific volume separator character.
static std::vector< char > get_invalid_path_chars() noexcept
Gets an array containing the characters that are not allowed in path names.
static xtd::ustring combine(const std::initializer_list< xtd::ustring > &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::ustring combine(path_t paths) noexcept
Combines path strings array.
Definition: path.h:98
static char directory_separator_char() noexcept
Provides a platform-specific character used to separate directory levels in a path string that reflec...
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
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:38
#define core_export_
Define shared library export.
Definition: core_export.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17