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.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include "../core_export.h"
7 #include "../date_time.h"
8 #include "../static.h"
9 #include "directory_info.h"
10 
12 namespace xtd {
14  namespace io {
95  class core_export_ directory static_ {
96  public:
98  class directory_iterator : public std::iterator<std::input_iterator_tag, xtd::ustring> {
99  explicit directory_iterator(const xtd::ustring& path, const xtd::ustring& pattern);
100  public:
103  directory_iterator(const directory_iterator&) = default;
105 
106  directory_iterator& operator++();
107  directory_iterator operator++(int);
108  bool operator==(directory_iterator other) const;
109  bool operator!=(directory_iterator other) const {return !operator==(other);}
110  value_type operator*() const;
112 
113  private:
114  friend xtd::io::directory;
115  struct data;
116  std::shared_ptr<data> data_;
117  };
118 
120  class file_iterator : public std::iterator<std::input_iterator_tag, xtd::ustring> {
121  explicit file_iterator(const std::string& path, const std::string& pattern);
122  public:
124  file_iterator();
125  file_iterator(const file_iterator&) = default;
126  file_iterator(file_iterator&&) = default;
127 
128  file_iterator& operator++();
129  file_iterator operator++(int);
130  bool operator==(file_iterator other) const;
131  bool operator!=(file_iterator other) const {return !operator==(other);}
132  value_type operator*() const;
134 
135  private:
136  friend xtd::io::directory;
137  struct data;
138  std::shared_ptr<data> data_;
139  };
140 
142  class file_system_entry_iterator : public std::iterator<std::input_iterator_tag, xtd::ustring> {
143  explicit file_system_entry_iterator(const std::string& path, const std::string& pattern);
144  public:
149 
150  file_system_entry_iterator& operator++();
151  file_system_entry_iterator operator++(int);
152  bool operator==(file_system_entry_iterator other) const;
153  bool operator!=(file_system_entry_iterator other) const {return !operator==(other);}
154  value_type operator*() const;
156 
157  private:
158  friend xtd::io::directory;
159  struct data;
160  std::shared_ptr<data> data_;
161  };
162 
164 
223  static xtd::io::directory_info create_directory(const xtd::ustring& path);
224 
267  static xtd::io::directory::directory_iterator enumerate_directories(const xtd::ustring& path);
320  static xtd::io::directory::directory_iterator enumerate_directories(const xtd::ustring& path, const xtd::ustring& search_pattern);
321 
361  static xtd::io::directory::file_iterator enumerate_files(const xtd::ustring& path);
409  static xtd::io::directory::file_iterator enumerate_files(const xtd::ustring& path, const xtd::ustring& search_pattern);
410 
421  static xtd::io::directory::file_system_entry_iterator enumerate_file_system_entries(const xtd::ustring& path);
440  static xtd::io::directory::file_system_entry_iterator enumerate_file_system_entries(const xtd::ustring& path, const xtd::ustring& search_pattern);
441 
497  static bool exists(const xtd::ustring& path);
498 
542  static xtd::date_time get_creation_time(const xtd::ustring& path);
543 
585  static xtd::ustring get_current_directory();
586 
648  static std::vector<xtd::ustring> get_directories(const xtd::ustring& path);
696  static std::vector<xtd::ustring> get_directories(const xtd::ustring& path, const xtd::ustring& search_pattern);
697 
738  static xtd::ustring get_directory_root(const xtd::ustring& path);
739 
802  static std::vector<xtd::ustring> get_files(const xtd::ustring& path);
856  static std::vector<xtd::ustring> get_files(const xtd::ustring& path, const xtd::ustring& search_pattern);
857 
970  static std::vector<xtd::ustring> get_file_system_entries(const xtd::ustring& path);
1096  static std::vector<xtd::ustring> get_file_system_entries(const xtd::ustring& path, const xtd::ustring& search_pattern);
1097 
1149  static xtd::date_time get_last_access_time(const xtd::ustring& path);
1150 
1201  static xtd::date_time get_last_write_time(const xtd::ustring& path);
1202 
1307  static std::vector<xtd::ustring> get_logical_drives();
1308 
1420  static xtd::io::directory_info get_parent(const xtd::ustring& path);
1421 
1457  static void move(const xtd::ustring& source_dir_name, const xtd::ustring& dest_dir_name);
1458 
1502  static void remove(const xtd::ustring& path);
1503 
1552  static void remove(const xtd::ustring& path, bool recursive);
1553 
1609  static void set_creation_time(const xtd::ustring& path, const xtd::date_time& creation_time);
1665  static void set_creation_time(const xtd::ustring& path, time_t creation_time);
1666 
1710  static void set_current_directory(const xtd::ustring& path);
1711 
1759  static void set_last_access_time(const xtd::ustring& path, const xtd::date_time& last_access_time);
1760 
1808  static void set_last_write_time(const xtd::ustring& path, const xtd::date_time& last_write_time);
1810  };
1811  }
1812 }
1813 
1815 namespace std {
1822 }
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:38
Represent file system iterator used by xtd::io::directory.
Definition: directory.h:142
Represent file iterator used by xtd::io::directory.
Definition: directory.h:120
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
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition: directory_info.h:125
Represent directory iterator used by xtd::io::directory.
Definition: directory.h:98
Performs operations on std::basic_string instances that contain file or directory path information...
Definition: path.h:32
Represents an instant in time, typically expressed as a date and time of day.
Definition: date_time.h:71
The operating system is other.
Contains xtd::io::directory_info class.