30 #ifndef _GLIBCXX_EXPERIMENTAL_FS_DIR_H
31 #define _GLIBCXX_EXPERIMENTAL_FS_DIR_H 1
33 #if __cplusplus < 201103L
39 # include <bits/shared_ptr.h>
41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 namespace experimental
61 file_status(
file_type __ft = file_type::none,
62 perms __prms = perms::unknown) noexcept
63 : _M_type(__ft), _M_perms(__prms) { }
65 file_status(
const file_status&) noexcept =
default;
66 file_status(file_status&&) noexcept = default;
67 ~file_status() = default;
69 file_status& operator=(const file_status&) noexcept = default;
70 file_status& operator=(file_status&&) noexcept = default;
73 file_type type() const noexcept {
return _M_type; }
74 perms permissions() const noexcept {
return _M_perms; }
77 void type(
file_type __ft) noexcept { _M_type = __ft; }
78 void permissions(
perms __prms) noexcept { _M_perms = __prms; }
85 _GLIBCXX_BEGIN_NAMESPACE_CXX11
91 directory_entry() noexcept = default;
92 directory_entry(const directory_entry&) = default;
93 directory_entry(directory_entry&&) noexcept = default;
94 explicit directory_entry(const filesystem::path& __p) : _M_path(__p) { }
95 ~directory_entry() =
default;
98 directory_entry& operator=(
const directory_entry&) =
default;
99 directory_entry& operator=(directory_entry&&) noexcept = default;
101 void assign(const filesystem::path& __p) { _M_path = __p; }
104 replace_filename(
const filesystem::path& __p)
105 { _M_path = _M_path.parent_path() / __p; }
108 const filesystem::path& path() const noexcept {
return _M_path; }
109 operator const filesystem::path&()
const noexcept {
return _M_path; }
113 {
return filesystem::status(_M_path); }
116 status(error_code& __ec)
const noexcept
117 {
return filesystem::status(_M_path, __ec); }
120 symlink_status()
const
121 {
return filesystem::symlink_status(_M_path); }
124 symlink_status(error_code& __ec)
const noexcept
125 {
return filesystem::symlink_status(_M_path, __ec); }
128 operator< (
const directory_entry& __rhs)
const noexcept
129 {
return _M_path < __rhs._M_path; }
132 operator==(
const directory_entry& __rhs)
const noexcept
133 {
return _M_path == __rhs._M_path; }
136 operator!=(
const directory_entry& __rhs)
const noexcept
137 {
return _M_path != __rhs._M_path; }
140 operator<=(
const directory_entry& __rhs)
const noexcept
141 {
return _M_path <= __rhs._M_path; }
144 operator> (
const directory_entry& __rhs)
const noexcept
145 {
return _M_path > __rhs._M_path; }
148 operator>=(
const directory_entry& __rhs)
const noexcept
149 {
return _M_path >= __rhs._M_path; }
152 filesystem::path _M_path;
156 class directory_iterator;
157 class recursive_directory_iterator;
159 struct __directory_iterator_proxy
161 const directory_entry&
operator*() const& noexcept {
return _M_entry; }
166 friend class directory_iterator;
167 friend class recursive_directory_iterator;
170 __directory_iterator_proxy(
const directory_entry& __e) : _M_entry(__e) { }
172 directory_entry _M_entry;
175 class directory_iterator
178 typedef directory_entry value_type;
179 typedef ptrdiff_t difference_type;
180 typedef const directory_entry* pointer;
181 typedef const directory_entry& reference;
182 typedef input_iterator_tag iterator_category;
184 directory_iterator() =
default;
187 directory_iterator(
const path& __p)
191 : directory_iterator(__p, __options, nullptr) { }
193 directory_iterator(
const path& __p, error_code& __ec) noexcept
194 : directory_iterator(__p, directory_options::none, __ec) { }
196 directory_iterator(
const path& __p,
198 error_code& __ec) noexcept
199 : directory_iterator(__p, __options, &__ec) { }
201 directory_iterator(
const directory_iterator& __rhs) =
default;
203 directory_iterator(directory_iterator&& __rhs) noexcept =
default;
205 ~directory_iterator() =
default;
208 operator=(
const directory_iterator& __rhs) =
default;
211 operator=(directory_iterator&& __rhs) noexcept =
default;
213 const directory_entry&
operator*()
const;
214 const directory_entry* operator->()
const {
return &**
this; }
215 directory_iterator& operator++();
216 directory_iterator& increment(error_code& __ec) noexcept;
218 __directory_iterator_proxy operator++(
int)
220 __directory_iterator_proxy __pr{**
this};
229 operator==(
const directory_iterator& __lhs,
230 const directory_iterator& __rhs);
232 friend class recursive_directory_iterator;
237 inline directory_iterator
238 begin(directory_iterator __iter) noexcept
241 inline directory_iterator
242 end(directory_iterator) noexcept
243 {
return directory_iterator(); }
246 operator==(
const directory_iterator& __lhs,
const directory_iterator& __rhs)
248 return !__rhs._M_dir.owner_before(__lhs._M_dir)
249 && !__lhs._M_dir.owner_before(__rhs._M_dir);
253 operator!=(
const directory_iterator& __lhs,
const directory_iterator& __rhs)
254 {
return !(__lhs == __rhs); }
256 class recursive_directory_iterator
259 typedef directory_entry value_type;
260 typedef ptrdiff_t difference_type;
261 typedef const directory_entry* pointer;
262 typedef const directory_entry& reference;
263 typedef input_iterator_tag iterator_category;
265 recursive_directory_iterator() =
default;
268 recursive_directory_iterator(
const path& __p)
272 : recursive_directory_iterator(__p, __options, nullptr) { }
274 recursive_directory_iterator(
const path& __p,
276 error_code& __ec) noexcept
277 : recursive_directory_iterator(__p, __options, &__ec) { }
279 recursive_directory_iterator(
const path& __p, error_code& __ec) noexcept
280 : recursive_directory_iterator(__p, directory_options::none, &__ec) { }
282 recursive_directory_iterator(
283 const recursive_directory_iterator&) =
default;
285 recursive_directory_iterator(recursive_directory_iterator&&) =
default;
287 ~recursive_directory_iterator();
292 bool recursion_pending()
const {
return _M_pending; }
294 const directory_entry&
operator*()
const;
295 const directory_entry* operator->()
const {
return &**
this; }
298 recursive_directory_iterator&
299 operator=(
const recursive_directory_iterator& __rhs) noexcept;
300 recursive_directory_iterator&
301 operator=(recursive_directory_iterator&& __rhs) noexcept;
303 recursive_directory_iterator& operator++();
304 recursive_directory_iterator& increment(error_code& __ec) noexcept;
306 __directory_iterator_proxy operator++(
int)
308 __directory_iterator_proxy __pr{**
this};
314 void pop(error_code&);
316 void disable_recursion_pending() { _M_pending =
false; }
322 operator==(
const recursive_directory_iterator& __lhs,
323 const recursive_directory_iterator& __rhs);
328 bool _M_pending =
false;
331 inline recursive_directory_iterator
332 begin(recursive_directory_iterator __iter) noexcept
335 inline recursive_directory_iterator
336 end(recursive_directory_iterator) noexcept
337 {
return recursive_directory_iterator(); }
340 operator==(
const recursive_directory_iterator& __lhs,
341 const recursive_directory_iterator& __rhs)
343 return !__rhs._M_dirs.owner_before(__lhs._M_dirs)
344 && !__lhs._M_dirs.owner_before(__rhs._M_dirs);
348 operator!=(
const recursive_directory_iterator& __lhs,
349 const recursive_directory_iterator& __rhs)
350 {
return !(__lhs == __rhs); }
352 _GLIBCXX_END_NAMESPACE_CXX11
359 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
perms
Bitmask type representing file access permissions.
directory_options
Bitmask type controlling directory iteration.
file_type
Enumerated type representing the type of a file.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
ISO C++ entities toplevel namespace is std.