xtd 0.2.0
Loading...
Searching...
No Matches
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
12//#include <iostream>
13
15namespace xtd {
17 namespace io {
34 public:
36
45 template<typename char_t>
46 [[nodiscard]] static auto alt_directory_separator_char() noexcept -> char_t {return static_cast<char_t>(alt_directory_separator_char());}
47
55 [[nodiscard]] static auto alt_directory_separator_char() noexcept -> char;
56
63 template<typename char_t>
64 [[nodiscard]] static auto directory_separator_char() noexcept -> char_t {
65 return static_cast<char_t>(directory_separator_char());
66 }
67
74 [[nodiscard]] static auto directory_separator_char() noexcept -> char;
75
80 template<typename char_t>
81 [[nodiscard]] static auto path_separator() noexcept -> char_t {return static_cast<char_t>(path_separator());}
82
87 [[nodiscard]] static auto path_separator() noexcept -> char;
88
93 template<typename char_t>
94 [[nodiscard]] static auto volume_separator_char() noexcept -> char_t {return static_cast<char_t>(volume_separator_char());}
95
100 [[nodiscard]] static auto volume_separator_char() noexcept -> char;
102
104
117 [[nodiscard]] static auto change_extension(const xtd::string& path, const xtd::string& extension) -> xtd::string;
118
124 [[nodiscard]] static auto combine(const xtd::string& path1, const xtd::string& path2) -> xtd::string;
125
132 template<typename type1_t, typename type2_t, typename type3_t>
133 [[nodiscard]] static auto combine(type1_t path1, type2_t path2, type3_t path3) noexcept {
134 return combine(combine(path1, path2), path3);
135 }
136
144 template<typename type1_t, typename type2_t, typename type3_t, typename type4_t>
145 [[nodiscard]] static auto combine(type1_t path1, type2_t path2, type3_t path3, type4_t path4) noexcept {
146 return combine(combine(combine(path1, path2), path3), path4);
147 }
148
153 template<typename path_t>
154 [[nodiscard]] static auto combine(path_t paths) noexcept -> xtd::string {
155 xtd::string result;
156 std::for_each(paths.begin(), paths.end(), [&](const auto& path) {result = combine(result, path);});
157 return result;
158 }
159
164 [[nodiscard]] static auto combine(const std::initializer_list<xtd::string>& paths) noexcept -> xtd::string;
165
170 [[nodiscard]] static auto get_directory_name(const xtd::string& path) -> xtd::string;
171
176 [[nodiscard]] static auto get_extension(const xtd::string& path) -> xtd::string;
177
182 [[nodiscard]] static auto get_file_name(const xtd::string& path) -> xtd::string;
183
188 [[nodiscard]] static auto get_file_name_without_extension(const xtd::string& path) -> xtd::string;
189
193 [[nodiscard]] static auto get_full_path(const xtd::string& path) -> xtd::string;
194
198 template<typename char_t>
199 [[nodiscard]] static auto get_invalid_path_chars() noexcept -> xtd::array<char_t> {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};}
200
204 [[nodiscard]] static auto get_invalid_path_chars() noexcept -> xtd::array<char>;
205
211 [[nodiscard]] static auto get_path_root(const xtd::string& path) -> xtd::string;
212
217 [[nodiscard]] static auto get_random_file_name() -> xtd::string;
223 [[nodiscard]] static auto get_random_file_name(xtd::usize name_length) -> xtd::string;
229 [[nodiscard]] static auto get_random_file_name(xtd::usize name_size, xtd::usize extension_size) -> xtd::string;
230
236 [[nodiscard]] static auto get_temp_file_name() -> xtd::string;
237
245 [[nodiscard]] static auto get_temp_path() noexcept -> xtd::string;
246
252 [[nodiscard]] static auto has_extension(const xtd::string& path) -> bool;
253
259 [[nodiscard]] static auto is_path_rooted(const xtd::string& path) -> bool;
261
262 private:
263 [[nodiscard]] static auto __get_index_path_rooted(const xtd::string& path) -> int32;
264 [[nodiscard]] static auto __is_drive(const xtd::string& path) noexcept -> bool;
265 };
266 }
267}
Contains xtd::array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.hpp:33
static auto directory_separator_char() noexcept -> char
Provides a platform-specific character used to separate directory levels in a path string that reflec...
static auto get_directory_name(const xtd::string &path) -> xtd::string
Returns the directory information for the specified path string.
static auto combine(path_t paths) noexcept -> xtd::string
Combines path strings array.
Definition path.hpp:154
static auto is_path_rooted(const xtd::string &path) -> bool
Gets a value indicating whether the specified path string contains absolute or relative path informat...
static auto directory_separator_char() noexcept -> char_t
Provides a platform-specific character used to separate directory levels in a path string that reflec...
Definition path.hpp:64
static auto get_temp_file_name() -> xtd::string
Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.
static auto volume_separator_char() noexcept -> char
Provides a platform-specific volume separator character.
static auto alt_directory_separator_char() noexcept -> char_t
Provides a platform-specific alternate character used to separate directory levels in a path string t...
Definition path.hpp:46
static auto get_path_root(const xtd::string &path) -> xtd::string
Gets the root directory information of the specified path.
static auto get_extension(const xtd::string &path) -> xtd::string
Returns the extension of 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:145
static auto has_extension(const xtd::string &path) -> bool
Determines whether a path includes a file name extension.
static auto alt_directory_separator_char() noexcept -> char
Provides a platform-specific alternate character used to separate directory levels in a path string t...
static auto get_invalid_path_chars() noexcept -> xtd::array< char >
Gets an array containing the characters that are not allowed in path names.
static auto combine(const std::initializer_list< xtd::string > &paths) noexcept -> xtd::string
Combines path strings array.
static auto path_separator() noexcept -> char
A platform-specific separator character used to separate path strings in environment variables.
static auto change_extension(const xtd::string &path, const xtd::string &extension) -> xtd::string
Changes the extension of a path string.
static auto get_temp_path() noexcept -> xtd::string
Returns the path of the current user's temporary folder.
static auto volume_separator_char() noexcept -> char_t
Provides a platform-specific volume separator character.
Definition path.hpp:94
static auto path_separator() noexcept -> char_t
A platform-specific separator character used to separate path strings in environment variables.
Definition path.hpp:81
static auto get_invalid_path_chars() noexcept -> xtd::array< char_t >
Gets an array containing the characters that are not allowed in path names.
Definition path.hpp:199
static auto combine(const xtd::string &path1, const xtd::string &path2) -> xtd::string
Combines two path strings.
static auto get_file_name_without_extension(const xtd::string &path) -> xtd::string
Returns the file name of the specified path string without the extension.
static auto get_random_file_name() -> xtd::string
Returns a random folder name or file name.
static auto get_file_name(const xtd::string &path) -> xtd::string
Returns the file name and extension of the specified path string.
static auto get_full_path(const xtd::string &path) -> xtd::string
Returns the absolute path for the specified path string.
Contains core_export_ keyword.
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.hpp:38
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::static_object class.
Contains xtd::string alias.