xtd 0.2.0
Loading...
Searching...
No Matches
directory.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "directory_info.hpp"
6#include "search_option.hpp"
7#include "../array.hpp"
8#include "../core_export.hpp"
9#include "../date_time.hpp"
10#include "../iequatable.hpp"
11#include "../static.hpp"
12#include <tuple>
13
15namespace xtd {
17 namespace io {
104 public:
106 class directory_iterator : public xtd::iequatable<directory_iterator> {
107 struct data;
108
109 explicit directory_iterator(const xtd::string& path, const xtd::string& pattern);
110 public:
112 using iterator_category = std::input_iterator_tag;
113 using value_type = xtd::string;
114 using difference_type = xtd::string;
115 using pointer = xtd::string*;
116 using reference = xtd::string&;
117
118 directory_iterator();
119 directory_iterator(const directory_iterator&) = default;
120 directory_iterator(directory_iterator&&) = default;
121
122 directory_iterator& operator ++();
123 directory_iterator operator ++(int32);
124 value_type operator *() const;
127 bool equals(const directory_iterator& other) const noexcept override;
129
130 private:
131 friend xtd::io::directory;
132
133 xtd::sptr<data> data_;
134 };
135
137 class file_iterator : public xtd::iequatable<file_iterator> {
138 struct data;
139
140 explicit file_iterator(const std::string& path, const std::string& pattern);
141 public:
143 using iterator_category = std::input_iterator_tag;
144 using value_type = xtd::string;
145 using difference_type = xtd::string;
146 using pointer = xtd::string*;
147 using reference = xtd::string&;
148
149 file_iterator();
150 file_iterator(const file_iterator&) = default;
151 file_iterator(file_iterator&&) = default;
152
153 file_iterator& operator ++();
154 file_iterator operator ++(int);
155 value_type operator *() const;
158 bool equals(const file_iterator& other) const noexcept override;
160
161 private:
162 friend xtd::io::directory;
163
164 xtd::sptr<data> data_;
165 };
166
168 class file_system_entry_iterator : public xtd::iequatable<file_system_entry_iterator> {
169 struct data;
170
171 explicit file_system_entry_iterator(const std::string& path, const std::string& pattern);
172 public:
174 using iterator_category = std::input_iterator_tag;
175 using value_type = xtd::string;
176 using difference_type = xtd::string;
177 using pointer = xtd::string*;
178 using reference = xtd::string&;
179
180 file_system_entry_iterator();
181 file_system_entry_iterator(const file_system_entry_iterator&) = default;
182 file_system_entry_iterator(file_system_entry_iterator&&) = default;
183
184 file_system_entry_iterator& operator ++();
185 file_system_entry_iterator operator ++(int32);
186 value_type operator *() const;
189 bool equals(const file_system_entry_iterator& other) const noexcept override;
191
192 private:
193 friend xtd::io::directory;
194
195 xtd::sptr<data> data_;
196 };
197
199
259
356
445
476
532 static bool exists(const xtd::string& path);
533
576
619
793
910 static xtd::array<xtd::string> get_files(const xtd::string& path, const xtd::string& search_pattern);
966
1205
1257
1308
1414
1527
1533
1569 static void move(const xtd::string& source_dir_name, const xtd::string& dest_dir_name);
1570
1614 static void remove(const xtd::string& path);
1615
1664 static void remove(const xtd::string& path, bool recursive);
1665
1721 static void set_creation_time(const xtd::string& path, const xtd::date_time& creation_time);
1777 static void set_creation_time(const xtd::string& path, time_t creation_time);
1778
1823
1870 static void set_last_access_time(const xtd::string& path, const xtd::date_time& last_access_time);
1871
1918 static void set_last_write_time(const xtd::string& path, const xtd::date_time& last_write_time);
1919
1932
1933 private:
1934 static std::tuple<time_t, time_t, time_t> get_file_times(const string& path);
1935 };
1936 }
1937}
Contains xtd::array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
virtual bool equals(const directory_iterator &) const noexcept=0
Represent directory iterator used by xtd::io::directory.
Definition directory.hpp:106
Represent file iterator used by xtd::io::directory.
Definition directory.hpp:137
Represent file system iterator used by xtd::io::directory.
Definition directory.hpp:168
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.hpp:130
Exposes static methods for creating, moving, and enumerating through directories and subdirectories....
Definition directory.hpp:103
static bool exists(const xtd::string &path)
Determines whether the given path refers to an existing directory on disk.
static void set_last_write_time(const xtd::string &path, const xtd::date_time &last_write_time)
Sets the date and time a directory was last written to.
static xtd::array< xtd::string > get_files(const xtd::string &path, const xtd::string &search_pattern)
Returns the names of files (including their paths) that match the specified search pattern in the spe...
static xtd::date_time get_creation_time(const xtd::string &path)
Gets the creation date and time of a directory.
static xtd::io::directory::file_system_entry_iterator enumerate_file_system_entries(const xtd::string &path)
Returns an enumerable collection of file names and directory names in a specified path.
static xtd::array< xtd::string > get_file_system_entries(const xtd::string &path, const xtd::string &search_pattern)
Returns an array of file names and directory names that match a search pattern in a specified path.
static void set_current_directory(const xtd::string &path)
Sets the application's current working directory to the specified directory.
static xtd::io::directory::file_system_entry_iterator enumerate_file_system_entries(const xtd::string &path, const xtd::string &search_pattern)
Returns an enumerable collection of file names and directory names that match a search pattern in a s...
static xtd::io::directory::file_iterator enumerate_files(const xtd::string &path)
Returns an enumerable collection of full file names in a specified path.
static xtd::array< xtd::string > get_files(const xtd::string &path)
Returns the names of files (including their paths) in the specified directory.
static void move(const xtd::string &source_dir_name, const xtd::string &dest_dir_name)
Moves a file or a directory and its contents to a new location.
static xtd::io::directory::file_iterator enumerate_files(const xtd::string &path, const xtd::string &search_pattern)
Returns an enumerable collection of full file names that match a search pattern in a specified path.
static void set_permissions(const xtd::string &path, xtd::io::file_permissions permissions)
Sets the specified xtd::io::file_permissions of the directory on the specified path.
static xtd::date_time get_last_write_time(const xtd::string &path)
Returns the date and time the specified file or directory was last written to.
static xtd::io::directory::directory_iterator enumerate_directories(const xtd::string &path)
Returns an enumerable collection of directory full names in a specified path.
static xtd::io::directory_info get_parent(const xtd::string &path)
Retrieves the parent directory of the specified path, including both absolute and relative paths.
static xtd::array< xtd::string > get_directories(const xtd::string &path)
Returns the names of subdirectories (including their paths) in the specified directory.
static xtd::array< xtd::string > get_directories(const xtd::string &path, const xtd::string &search_pattern)
Returns the names of subdirectories (including their paths) that match the specified search pattern i...
static void remove(const xtd::string &path)
Deletes an empty directory from a specified path.
static xtd::array< xtd::string > get_directories(const xtd::string &path, const xtd::string &search_pattern, xtd::io::search_option search_option)
eturns the names of the subdirectories (including their paths) that match the specified search patter...
static void set_last_access_time(const xtd::string &path, const xtd::date_time &last_access_time)
Sets the date and time the specified file or directory was last accessed.
static xtd::array< xtd::string > get_file_system_entries(const xtd::string &path)
Returns the names of all files and subdirectories in a specified path.
static xtd::io::file_permissions get_permissions(const xtd::string &path)
Gets the xtd::io::file_permissions of the directory on the path.
static xtd::array< xtd::string > get_logical_drives()
Retrieves the names of the logical drives on this computer in the form "<drive letter>:\".
static xtd::io::directory_info create_directory(const xtd::string &path)
Creates all directories and subdirectories in the specified path unless they already exist.
static xtd::date_time get_last_access_time(const xtd::string &path)
Returns the date and time the specified file or directory was last accessed.
static void set_creation_time(const xtd::string &path, const xtd::date_time &creation_time)
Sets the creation date and time for the specified file or directory.
static xtd::io::directory::directory_iterator enumerate_directories(const xtd::string &path, const xtd::string &search_pattern)
Returns an enumerable collection of directory full names that match a search pattern in a specified p...
static void set_creation_time(const xtd::string &path, time_t creation_time)
Sets the creation date and time for the specified file or directory.
static xtd::string get_current_directory()
Gets the current working directory of the application.
static xtd::string get_directory_root(const xtd::string &path)
Returns the volume information, root information, or both for the specified path.
static void remove(const xtd::string &path, bool recursive)
Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
static xtd::array< xtd::string > get_files(const xtd::string &path, const xtd::string &search_pattern, xtd::io::search_option search_option)
Returns the names of files (including their paths) that match the specified search pattern in the spe...
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.hpp:37
Contains core_export_ keyword.
Contains xtd::date_time class.
Contains xtd::io::directory_info class.
#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
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
file_permissions
Provides permissions for files and directories.
Definition file_permissions.hpp:24
search_option
Specifies whether to search the current directory, or the current directory and all subdirectories.
Definition search_option.hpp:25
@ end
Specifies the end of a stream.
Definition seek_origin.hpp:22
@ begin
Specifies the beginning of a stream.
Definition seek_origin.hpp:18
@ other
The operating system is other.
Definition platform_id.hpp:58
Contains xtd::iequatable interface.
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
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::io::search_option enum class.
Contains xtd::static_object class.