xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
directory_info.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <iterator>
7 #include <memory>
8 #include "file_system_info.h"
9 
11 namespace xtd {
13  namespace io {
15  class directory;
16  class file_info;
18 
125  class core_export_ directory_info final : public xtd::io::file_system_info {
126  public:
128  class directory_iterator : public std::iterator<std::input_iterator_tag, xtd::io::directory_info> {
129  explicit directory_iterator(const xtd::ustring& path, const xtd::ustring& pattern);
130  public:
133  directory_iterator(const directory_iterator&) = default;
135 
136  directory_iterator& operator++();
137  directory_iterator operator++(int);
138  bool operator==(directory_iterator other) const;
139  bool operator!=(directory_iterator other) const {return !operator==(other);}
140  value_type operator*() const;
142 
143  private:
144  friend xtd::io::directory;
146  struct data;
147  std::shared_ptr<data> data_;
148  };
149 
151  class file_iterator : public std::iterator<std::input_iterator_tag, xtd::io::file_info> {
152  explicit file_iterator(const std::string& path, const std::string& pattern);
153  public:
155  file_iterator();
156  file_iterator(const file_iterator&) = default;
157  file_iterator(file_iterator&&) = default;
158 
159  file_iterator& operator++();
160  file_iterator operator++(int);
161  bool operator==(file_iterator other) const;
162  bool operator!=(file_iterator other) const {return !operator==(other);}
163  value_type operator*() const;
165 
166  private:
167  friend xtd::io::directory;
169  struct data;
170  std::shared_ptr<data> data_;
171  };
172 
174  class file_system_info_iterator : public std::iterator<std::input_iterator_tag, std::shared_ptr<xtd::io::file_system_info>> {
175  explicit file_system_info_iterator(const std::string& path, const std::string& pattern);
176  public:
181 
182  file_system_info_iterator& operator++();
183  file_system_info_iterator operator++(int);
184  bool operator==(file_system_info_iterator other) const;
185  bool operator!=(file_system_info_iterator other) const {return !operator==(other);}
186  value_type operator*() const;
188 
189  private:
190  friend xtd::io::directory;
192  struct data;
193  std::shared_ptr<data> data_;
194  };
195 
197 
200  static const directory_info empty;
202 
204 
245  explicit directory_info(const xtd::ustring& path);
247 
249 
295  bool exists() const override;
296 
321  xtd::ustring name() const override;
322 
362  xtd::io::directory_info parent() const;
363 
401  xtd::io::directory_info root() const;
403 
405 
449  void create();
450 
496  xtd::io::directory_info create_subdirectory(const xtd::ustring& path) const;
497 
535  xtd::io::directory_info::directory_iterator enumerate_directories() const;
556  xtd::io::directory_info::directory_iterator enumerate_directories(const xtd::ustring& search_pattern) const;
557 
655  xtd::io::directory_info::file_iterator enumerate_files() const;
732  xtd::io::directory_info::file_iterator enumerate_files(const xtd::ustring& search_pattern) const;
733 
748  xtd::io::directory_info::file_system_info_iterator enumerate_file_system_infos() const;
770  xtd::io::directory_info::file_system_info_iterator enumerate_file_system_infos(const xtd::ustring& search_pattern) const;
771 
809  std::vector<xtd::io::directory_info> get_directories() const;
857  std::vector<xtd::io::directory_info> get_directories(const xtd::ustring& search_pattern) const;
858 
928  std::vector<xtd::io::file_info> get_files() const;
1005  std::vector<xtd::io::file_info> get_files(const xtd::ustring& search_pattern) const;
1006 
1090  std::vector<std::shared_ptr<xtd::io::file_system_info>> get_file_system_infos() const;
1185  std::vector<std::shared_ptr<xtd::io::file_system_info>> get_file_system_infos(const xtd::ustring& search_pattern) const;
1186 
1239  void move_to(const xtd::ustring& dest_dir_name);
1240 
1278  void remove() const override;
1279 
1323  void remove(bool recursive) const;
1325 
1326  private:
1327  directory_info() = default;
1328  };
1329  }
1330 }
1331 
1333 namespace std {
1340 }
The file is a directory.
Provides the base class for both xtd::io::file_info and xtd::io::directory_info objects.
Definition: file_system_info.h:83
Represent directory iterator used by xtd::io::directory_info.
Definition: directory_info.h:128
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Exposes static methods for creating, moving, and enumerating through directories and subdirectories...
Definition: directory.h:95
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
Contains xtd::io::file_system_info class.
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition: directory_info.h:125
Represent file iterator used by xtd::io::directory_info.
Definition: directory_info.h:151
Performs operations on std::basic_string instances that contain file or directory path information...
Definition: path.h:32
The operating system is other.
static const directory_info empty
Represents the uninitialized xtd::io::directory_info object. This field is constant.
Definition: directory_info.h:200
Represent file system iterator used by xtd::io::directory_info.
Definition: directory_info.h:174