xtd 0.2.0
Loading...
Searching...
No Matches
directory_info.h
Go to the documentation of this file.
1
4#pragma once
5#include "file_system_info.h"
6#include "../iequatable.h"
7#include <iterator>
8#include <memory>
9
11namespace xtd {
13 namespace io {
15 class directory;
16 class file_info;
18
130 public:
132 class directory_iterator : public xtd::iequatable<directory_iterator> {
133 struct data;
134
135 explicit directory_iterator(const xtd::string& path, const xtd::string& pattern);
136 public:
138 using iterator_category = std::input_iterator_tag;
139 using value_type = xtd::io::directory_info;
140 using difference_type = xtd::io::directory_info;
141 using pointer = xtd::io::directory_info*;
142 using reference = xtd::io::directory_info&;
143
145 directory_iterator(const directory_iterator&) = default;
147
148 directory_iterator& operator ++();
149 directory_iterator operator ++(int32);
150 value_type operator *() const;
153 bool equals(const directory_iterator& other) const noexcept override;
154
155 xtd::string path() const;
156 xtd::string pattern() const;
158
159 private:
160 friend xtd::io::directory;
162
163 xtd::sptr<data> data_;
164 };
165
167 class file_iterator : public xtd::iequatable<file_iterator> {
168 struct data;
169
170 explicit file_iterator(const std::string& path, const std::string& pattern);
171 public:
173 using iterator_category = std::input_iterator_tag;
174 using value_type = xtd::io::file_info;
175 using difference_type = xtd::io::file_info;
176 using pointer = xtd::io::file_info*;
177 using reference = xtd::io::file_info&;
178
180 file_iterator(const file_iterator&) = default;
181 file_iterator(file_iterator&&) = default;
182
183 file_iterator& operator ++();
184 file_iterator operator ++(int32);
185 value_type operator *() const;
188 bool equals(const file_iterator& other) const noexcept override;
189
190 xtd::string path() const;
191 xtd::string pattern() const;
193
194 private:
195 friend xtd::io::directory;
197
198 xtd::sptr<data> data_;
199 };
200
202 class file_system_info_iterator : public xtd::iequatable<file_system_info_iterator> {
203 struct data;
204
205 explicit file_system_info_iterator(const std::string& path, const std::string& pattern);
206 public:
208 using iterator_category = std::input_iterator_tag;
209 using value_type = xtd::sptr<xtd::io::file_system_info>;
210 using difference_type = xtd::sptr<xtd::io::file_system_info>;
211 using pointer = xtd::sptr<xtd::io::file_system_info>* ;
212 using reference = xtd::sptr<xtd::io::file_system_info>& ;
213
217
218 file_system_info_iterator& operator ++();
219 file_system_info_iterator operator ++(int32);
220 value_type operator *() const;
223 bool equals(const file_system_info_iterator& other) const noexcept override;
224
225 xtd::string path() const;
226 xtd::string pattern() const;
228
229 private:
230 friend xtd::io::directory;
232
233 xtd::sptr<data> data_;
234 };
235
237
240 static const directory_info empty;
242
244
287
289
335 bool exists() const override;
336
361 xtd::string name() const override;
362
403
443
445
489 void create();
490
537
597
773
811
849 std::vector<xtd::io::directory_info> get_directories() const;
897 std::vector<xtd::io::directory_info> get_directories(const xtd::string& search_pattern) const;
898
968 std::vector<xtd::io::file_info> get_files() const;
1045 std::vector<xtd::io::file_info> get_files(const xtd::string& search_pattern) const;
1046
1130 std::vector<xtd::sptr<xtd::io::file_system_info>> get_file_system_infos() const;
1225 std::vector<xtd::sptr<xtd::io::file_system_info>> get_file_system_infos(const xtd::string& search_pattern) const;
1226
1279 void move_to(const xtd::string& dest_dir_name);
1280
1318 void remove() const override;
1319
1363 void remove(bool recursive) const;
1365
1366 private:
1367 directory_info() = default;
1368 };
1369 }
1370}
Represents text as a sequence of character units.
Definition basic_string.h:79
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
Represent directory iterator used by xtd::io::directory_info.
Definition directory_info.h:132
Represent file iterator used by xtd::io::directory_info.
Definition directory_info.h:167
Represent file system iterator used by xtd::io::directory_info.
Definition directory_info.h:202
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.h:129
std::vector< xtd::io::directory_info > get_directories(const xtd::string &search_pattern) const
Returns an array of directories in the current DirectoryInfo matching the given search criteria.
directory_info(const xtd::string &path)
Initializes a new instance of the xtd::io::directory_info class on the specified path.
xtd::io::directory_info parent() const
Gets the parent directory of a specified subdirectory.
xtd::io::directory_info::file_system_info_iterator enumerate_file_system_infos() const
Returns an enumerable collection of file system information in the current directory.
xtd::io::directory_info::file_iterator enumerate_files(const xtd::string &search_pattern) const
Returns an enumerable collection of file information that matches a search pattern.
bool exists() const override
Gets a value indicating whether the directory exists.
void remove(bool recursive) const
Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.
void remove() const override
Deletes this xtd::io::directory_info if it is empty.
std::vector< xtd::io::file_info > get_files(const xtd::string &search_pattern) const
Returns a file list from the current directory matching the given search pattern.
xtd::io::directory_info::directory_iterator enumerate_directories(const xtd::string &search_pattern) const
Returns an enumerable collection of directory information that matches a specified search pattern.
std::vector< xtd::io::directory_info > get_directories() const
Returns the subdirectories of the current directory.
xtd::string name() const override
Gets the name of this xtd::io::directory_info instance.
void create()
Creates a directory.
std::vector< xtd::io::file_info > get_files() const
Returns a file list from the current directory.
std::vector< xtd::sptr< xtd::io::file_system_info > > get_file_system_infos() const
Returns an array of strongly typed xtd::io::file_system_info entries representing all the files and s...
xtd::io::directory_info create_subdirectory(const xtd::string &path) const
Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to...
std::vector< xtd::sptr< xtd::io::file_system_info > > get_file_system_infos(const xtd::string &search_pattern) const
Retrieves an array of strongly typed FileSystemInfo objects representing the files and subdirectories...
void move_to(const xtd::string &dest_dir_name)
Moves a DirectoryInfo instance and its contents to a new path.
xtd::io::directory_info::file_iterator enumerate_files() const
Returns an enumerable collection of file information in the current directory.
xtd::io::directory_info::directory_iterator enumerate_directories() const
Returns an enumerable collection of directory information in the current directory.
xtd::io::directory_info root() const
Gets the root portion of the directory.
static const directory_info empty
Represents the uninitialized xtd::io::directory_info object. This field is constant.
Definition directory_info.h:240
xtd::io::directory_info::file_system_info_iterator enumerate_file_system_infos(const xtd::string &search_pattern) const
Returns an enumerable collection of file system information that matches a specified search pattern.
Exposes static methods for creating, moving, and enumerating through directories and subdirectories....
Definition directory.h:101
Provides static methods for the creation, copying, deletion, moving, and opening of files,...
Definition file_info.h:41
Provides the base class for both xtd::io::file_info and xtd::io::directory_info objects.
Definition file_system_info.h:87
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.h:36
Contains xtd::io::file_system_info class.
#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
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
@ directory
The file is a directory.
@ 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