xtd 0.2.0
Loading...
Searching...
No Matches
directory.h
Go to the documentation of this file.
1
4#pragma once
5#include "directory_info.h"
6#include "../core_export.h"
7#include "../date_time.h"
8#include "../iequatable.h"
9#include "../static.h"
10#include <tuple>
11
13namespace xtd {
15 namespace io {
100 public:
102 class directory_iterator : public xtd::iequatable<directory_iterator> {
103 struct data;
104
105 explicit directory_iterator(const xtd::ustring& path, const xtd::ustring& pattern);
106 public:
108 using iterator_category = std::input_iterator_tag;
109 using value_type = xtd::ustring;
110 using difference_type = xtd::ustring;
111 using pointer = xtd::ustring*;
112 using reference = xtd::ustring&;
113
115 directory_iterator(const directory_iterator&) = default;
117
118 directory_iterator& operator ++();
119 directory_iterator operator ++(int32);
120 value_type operator *() const;
123 bool equals(const directory_iterator& other) const noexcept override;
125
126 private:
127 friend xtd::io::directory;
128
129 std::shared_ptr<data> data_;
130 };
131
133 class file_iterator : public xtd::iequatable<file_iterator> {
134 struct data;
135
136 explicit file_iterator(const std::string& path, const std::string& pattern);
137 public:
139 using iterator_category = std::input_iterator_tag;
140 using value_type = xtd::ustring;
141 using difference_type = xtd::ustring;
142 using pointer = xtd::ustring*;
143 using reference = xtd::ustring&;
144
146 file_iterator(const file_iterator&) = default;
147 file_iterator(file_iterator&&) = default;
148
149 file_iterator& operator ++();
150 file_iterator operator ++(int);
151 value_type operator *() const;
154 bool equals(const file_iterator& other) const noexcept override;
156
157 private:
158 friend xtd::io::directory;
159
160 std::shared_ptr<data> data_;
161 };
162
164 class file_system_entry_iterator : public xtd::iequatable<file_system_entry_iterator> {
165 struct data;
166
167 explicit file_system_entry_iterator(const std::string& path, const std::string& pattern);
168 public:
170 using iterator_category = std::input_iterator_tag;
171 using value_type = xtd::ustring;
172 using difference_type = xtd::ustring;
173 using pointer = xtd::ustring*;
174 using reference = xtd::ustring&;
175
179
180 file_system_entry_iterator& operator ++();
182 value_type operator *() const;
185 bool equals(const file_system_entry_iterator& other) const noexcept override;
187
188 private:
189 friend xtd::io::directory;
190
191 std::shared_ptr<data> data_;
192 };
193
195
255
352
441
472
528 static bool exists(const xtd::ustring& path);
529
572
615
677 static std::vector<xtd::ustring> get_directories(const xtd::ustring& path);
725 static std::vector<xtd::ustring> get_directories(const xtd::ustring& path, const xtd::ustring& search_pattern);
726
768
831 static std::vector<xtd::ustring> get_files(const xtd::ustring& path);
885 static std::vector<xtd::ustring> get_files(const xtd::ustring& path, const xtd::ustring& search_pattern);
886
999 static std::vector<xtd::ustring> get_file_system_entries(const xtd::ustring& path);
1124 static std::vector<xtd::ustring> get_file_system_entries(const xtd::ustring& path, const xtd::ustring& search_pattern);
1125
1178
1230
1335 static std::vector<xtd::ustring> get_logical_drives();
1336
1449
1455
1491 static void move(const xtd::ustring& source_dir_name, const xtd::ustring& dest_dir_name);
1492
1536 static void remove(const xtd::ustring& path);
1537
1586 static void remove(const xtd::ustring& path, bool recursive);
1587
1643 static void set_creation_time(const xtd::ustring& path, const xtd::date_time& creation_time);
1699 static void set_creation_time(const xtd::ustring& path, time_t creation_time);
1700
1745
1793 static void set_last_access_time(const xtd::ustring& path, const xtd::date_time& last_access_time);
1794
1842 static void set_last_write_time(const xtd::ustring& path, const xtd::date_time& last_write_time);
1843
1856
1857 private:
1858 static std::tuple<time_t, time_t, time_t> get_file_times(const ustring& path);
1859 };
1860 }
1861}
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.h:79
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
Represent directory iterator used by xtd::io::directory.
Definition directory.h:102
Represent file iterator used by xtd::io::directory.
Definition directory.h:133
Represent file system iterator used by xtd::io::directory.
Definition directory.h:164
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.h:127
Exposes static methods for creating, moving, and enumerating through directories and subdirectories....
Definition directory.h:99
static std::vector< xtd::ustring > get_files(const xtd::ustring &path)
Returns the names of files (including their paths) in the specified directory.
static std::vector< xtd::ustring > get_file_system_entries(const xtd::ustring &path)
Returns the names of all files and subdirectories in a specified path.
static void set_permissions(const xtd::ustring &path, xtd::io::file_permissions permissions)
Sets the specified xtd::io::file_permissions of the directory on the specified path.
static xtd::io::directory::file_system_entry_iterator enumerate_file_system_entries(const xtd::ustring &path, const xtd::ustring &search_pattern)
Returns an enumerable collection of file names and directory names that match a search pattern in a s...
static xtd::io::directory::directory_iterator enumerate_directories(const xtd::ustring &path)
Returns an enumerable collection of directory full names in a specified path.
static xtd::ustring get_current_directory()
Gets the current working directory of the application.
static void move(const xtd::ustring &source_dir_name, const xtd::ustring &dest_dir_name)
Moves a file or a directory and its contents to a new location.
static void set_last_write_time(const xtd::ustring &path, const xtd::date_time &last_write_time)
Sets the date and time a directory was last written to.
static std::vector< xtd::ustring > get_file_system_entries(const xtd::ustring &path, const xtd::ustring &search_pattern)
Returns an array of file names and directory names that match a search pattern in a specified path.
static xtd::date_time get_creation_time(const xtd::ustring &path)
Gets the creation date and time of a directory.
static xtd::io::directory::file_iterator enumerate_files(const xtd::ustring &path, const xtd::ustring &search_pattern)
Returns an enumerable collection of full file names that match a search pattern in a specified path.
static void remove(const xtd::ustring &path, bool recursive)
Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
static std::vector< xtd::ustring > get_directories(const xtd::ustring &path)
Returns the names of subdirectories (including their paths) in the specified directory.
static xtd::io::directory::file_system_entry_iterator enumerate_file_system_entries(const xtd::ustring &path)
Returns an enumerable collection of file names and directory names in a specified path.
static void remove(const xtd::ustring &path)
Deletes an empty directory from a specified path.
static xtd::io::directory::directory_iterator enumerate_directories(const xtd::ustring &path, const xtd::ustring &search_pattern)
Returns an enumerable collection of directory full names that match a search pattern in a specified p...
static std::vector< xtd::ustring > get_directories(const xtd::ustring &path, const xtd::ustring &search_pattern)
Returns the names of subdirectories (including their paths) that match the specified search pattern i...
static std::vector< xtd::ustring > get_logical_drives()
Retrieves the names of the logical drives on this computer in the form "<drive letter>:\".
static void set_last_access_time(const xtd::ustring &path, const xtd::date_time &last_access_time)
Sets the date and time the specified file or directory was last accessed.
static void set_current_directory(const xtd::ustring &path)
Sets the application's current working directory to the specified directory.
static void set_creation_time(const xtd::ustring &path, time_t creation_time)
Sets the creation date and time for the specified file or directory.
static void set_creation_time(const xtd::ustring &path, const xtd::date_time &creation_time)
Sets the creation date and time for the specified file or directory.
static xtd::date_time get_last_write_time(const xtd::ustring &path)
Returns the date and time the specified file or directory was last written to.
static bool exists(const xtd::ustring &path)
Determines whether the given path refers to an existing directory on disk.
static std::vector< xtd::ustring > get_files(const xtd::ustring &path, const xtd::ustring &search_pattern)
Returns the names of files (including their paths) that match the specified search pattern in the spe...
static xtd::io::file_permissions get_permissions(const xtd::ustring &path)
Gets the xtd::io::file_permissions of the directory on the path.
static xtd::date_time get_last_access_time(const xtd::ustring &path)
Returns the date and time the specified file or directory was last accessed.
static xtd::io::directory_info get_parent(const xtd::ustring &path)
Retrieves the parent directory of the specified path, including both absolute and relative paths.
static xtd::ustring get_directory_root(const xtd::ustring &path)
Returns the volume information, root information, or both for the specified path.
static xtd::io::directory::file_iterator enumerate_files(const xtd::ustring &path)
Returns an enumerable collection of full file names in a specified path.
static xtd::io::directory_info create_directory(const xtd::ustring &path)
Creates all directories and subdirectories in the specified path unless they already exist.
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.h:34
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
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.h:37
#define core_export_
Define shared library export.
Definition core_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
file_permissions
Provides permissions for files and directories.
Definition file_permissions.h:22
@ other
The operating system is other.
@ end
The END key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10