30 #ifndef _GLIBCXX_FS_DIR_H
31 #define _GLIBCXX_FS_DIR_H 1
33 #if __cplusplus >= 201703L
37 # include <bits/shared_ptr.h>
39 #if __cplusplus > 201703L
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
58 file_status() noexcept : file_status(file_type::none) {}
61 file_status(file_type __ft,
perms __prms = perms::unknown) noexcept
62 : _M_type(__ft), _M_perms(__prms) { }
64 file_status(
const file_status&) noexcept =
default;
65 file_status(file_status&&) noexcept = default;
66 ~file_status() = default;
68 file_status& operator=(const file_status&) noexcept = default;
69 file_status& operator=(file_status&&) noexcept = default;
72 file_type type() const noexcept {
return _M_type; }
73 perms permissions() const noexcept {
return _M_perms; }
76 void type(file_type __ft) noexcept { _M_type = __ft; }
77 void permissions(
perms __prms) noexcept { _M_perms = __prms; }
79 #if __cpp_lib_three_way_comparison
81 operator==(
const file_status&,
const file_status&) noexcept =
default;
89 _GLIBCXX_BEGIN_NAMESPACE_CXX11
92 class directory_iterator;
93 class recursive_directory_iterator;
100 directory_entry() noexcept = default;
101 directory_entry(const directory_entry&) = default;
102 directory_entry(directory_entry&&) noexcept = default;
105 directory_entry(const filesystem::path& __p)
109 directory_entry(
const filesystem::path& __p, error_code& __ec)
117 ~directory_entry() =
default;
120 directory_entry& operator=(
const directory_entry&) =
default;
121 directory_entry& operator=(directory_entry&&) noexcept = default;
124 assign(const filesystem::path& __p)
131 assign(
const filesystem::path& __p, error_code& __ec)
138 replace_filename(
const filesystem::path& __p)
140 _M_path.replace_filename(__p);
145 replace_filename(
const filesystem::path& __p, error_code& __ec)
147 _M_path.replace_filename(__p);
153 { _M_type = symlink_status().type(); }
156 refresh(error_code& __ec) noexcept
157 { _M_type = symlink_status(__ec).type(); }
160 const filesystem::path& path() const noexcept {
return _M_path; }
161 operator const filesystem::path& ()
const noexcept {
return _M_path; }
165 {
return filesystem::exists(file_status{_M_file_type()}); }
168 exists(error_code& __ec)
const noexcept
169 {
return filesystem::exists(file_status{_M_file_type(__ec)}); }
172 is_block_file()
const
173 {
return _M_file_type() == file_type::block; }
176 is_block_file(error_code& __ec)
const noexcept
177 {
return _M_file_type(__ec) == file_type::block; }
180 is_character_file()
const
181 {
return _M_file_type() == file_type::character; }
184 is_character_file(error_code& __ec)
const noexcept
185 {
return _M_file_type(__ec) == file_type::character; }
189 {
return _M_file_type() == file_type::directory; }
192 is_directory(error_code& __ec)
const noexcept
193 {
return _M_file_type(__ec) == file_type::directory; }
197 {
return _M_file_type() == file_type::fifo; }
200 is_fifo(error_code& __ec)
const noexcept
201 {
return _M_file_type(__ec) == file_type::fifo; }
205 {
return filesystem::is_other(file_status{_M_file_type()}); }
208 is_other(error_code& __ec)
const noexcept
209 {
return filesystem::is_other(file_status{_M_file_type(__ec)}); }
212 is_regular_file()
const
213 {
return _M_file_type() == file_type::regular; }
216 is_regular_file(error_code& __ec)
const noexcept
217 {
return _M_file_type(__ec) == file_type::regular; }
221 {
return _M_file_type() == file_type::socket; }
224 is_socket(error_code& __ec)
const noexcept
225 {
return _M_file_type(__ec) == file_type::socket; }
230 if (_M_type != file_type::none)
231 return _M_type == file_type::symlink;
232 return symlink_status().type() == file_type::symlink;
236 is_symlink(error_code& __ec)
const noexcept
238 if (_M_type != file_type::none)
239 return _M_type == file_type::symlink;
240 return symlink_status(__ec).type() == file_type::symlink;
245 {
return filesystem::file_size(_M_path); }
248 file_size(error_code& __ec)
const noexcept
249 {
return filesystem::file_size(_M_path, __ec); }
252 hard_link_count()
const
253 {
return filesystem::hard_link_count(_M_path); }
256 hard_link_count(error_code& __ec)
const noexcept
257 {
return filesystem::hard_link_count(_M_path, __ec); }
260 last_write_time()
const
261 {
return filesystem::last_write_time(_M_path); }
265 last_write_time(error_code& __ec)
const noexcept
266 {
return filesystem::last_write_time(_M_path, __ec); }
270 {
return filesystem::status(_M_path); }
273 status(error_code& __ec)
const noexcept
274 {
return filesystem::status(_M_path, __ec); }
277 symlink_status()
const
278 {
return filesystem::symlink_status(_M_path); }
281 symlink_status(error_code& __ec)
const noexcept
282 {
return filesystem::symlink_status(_M_path, __ec); }
285 operator==(
const directory_entry& __rhs)
const noexcept
286 {
return _M_path == __rhs._M_path; }
288 #if __cpp_lib_three_way_comparison
290 operator<=>(
const directory_entry& __rhs)
const noexcept
291 {
return _M_path <=> __rhs._M_path; }
294 operator!=(
const directory_entry& __rhs)
const noexcept
295 {
return _M_path != __rhs._M_path; }
298 operator< (
const directory_entry& __rhs)
const noexcept
299 {
return _M_path < __rhs._M_path; }
302 operator<=(
const directory_entry& __rhs)
const noexcept
303 {
return _M_path <= __rhs._M_path; }
306 operator> (
const directory_entry& __rhs)
const noexcept
307 {
return _M_path > __rhs._M_path; }
310 operator>=(
const directory_entry& __rhs)
const noexcept
311 {
return _M_path >= __rhs._M_path; }
316 friend class directory_iterator;
317 friend class recursive_directory_iterator;
321 template<
typename _CharT,
typename _Traits>
322 friend basic_ostream<_CharT, _Traits>&
323 operator<<(basic_ostream<_CharT, _Traits>& __os,
324 const directory_entry& __d)
325 {
return __os << __d.path(); }
327 directory_entry(
const filesystem::path& __p, file_type __t)
328 : _M_path(__p), _M_type(__t)
335 if (_M_type != file_type::none && _M_type != file_type::symlink)
337 return status().type();
342 _M_file_type(error_code& __ec)
const noexcept
344 if (_M_type != file_type::none && _M_type != file_type::symlink)
349 return status(__ec).type();
352 filesystem::path _M_path;
353 file_type _M_type = file_type::none;
357 struct __directory_iterator_proxy
359 const directory_entry&
operator*() const& noexcept {
return _M_entry; }
364 friend class directory_iterator;
365 friend class recursive_directory_iterator;
368 __directory_iterator_proxy(
const directory_entry& __e) : _M_entry(__e) { }
370 directory_entry _M_entry;
374 class directory_iterator
377 typedef directory_entry value_type;
378 typedef ptrdiff_t difference_type;
379 typedef const directory_entry* pointer;
380 typedef const directory_entry& reference;
381 typedef input_iterator_tag iterator_category;
383 directory_iterator() =
default;
386 directory_iterator(
const path& __p)
387 : directory_iterator(__p, directory_options::none, nullptr) { }
389 directory_iterator(
const path& __p, directory_options __options)
390 : directory_iterator(__p, __options, nullptr) { }
392 directory_iterator(
const path& __p, error_code& __ec)
393 : directory_iterator(__p, directory_options::none, __ec) { }
395 directory_iterator(
const path& __p, directory_options __options,
397 : directory_iterator(__p, __options, &__ec) { }
399 directory_iterator(
const directory_iterator& __rhs) =
default;
401 directory_iterator(directory_iterator&& __rhs) noexcept =
default;
403 ~directory_iterator() =
default;
406 operator=(
const directory_iterator& __rhs) =
default;
409 operator=(directory_iterator&& __rhs) noexcept =
default;
411 const directory_entry&
operator*() const noexcept;
412 const directory_entry* operator->() const noexcept {
return &**
this; }
413 directory_iterator& operator++();
414 directory_iterator& increment(error_code& __ec);
416 __directory_iterator_proxy operator++(
int)
418 __directory_iterator_proxy __pr{**
this};
424 directory_iterator(
const path&, directory_options, error_code*);
427 operator==(
const directory_iterator& __lhs,
428 const directory_iterator& __rhs) noexcept
430 return !__rhs._M_dir.owner_before(__lhs._M_dir)
431 && !__lhs._M_dir.owner_before(__rhs._M_dir);
435 operator!=(
const directory_iterator& __lhs,
436 const directory_iterator& __rhs) noexcept
437 {
return !(__lhs == __rhs); }
439 friend class recursive_directory_iterator;
441 std::__shared_ptr<_Dir> _M_dir;
450 inline directory_iterator
451 begin(directory_iterator __iter) noexcept
455 inline directory_iterator
456 end(directory_iterator) noexcept
457 {
return directory_iterator(); }
461 class recursive_directory_iterator
464 typedef directory_entry value_type;
465 typedef ptrdiff_t difference_type;
466 typedef const directory_entry* pointer;
467 typedef const directory_entry& reference;
468 typedef input_iterator_tag iterator_category;
470 recursive_directory_iterator() =
default;
473 recursive_directory_iterator(
const path& __p)
474 : recursive_directory_iterator(__p, directory_options::none, nullptr) { }
476 recursive_directory_iterator(
const path& __p, directory_options __options)
477 : recursive_directory_iterator(__p, __options, nullptr) { }
479 recursive_directory_iterator(
const path& __p, directory_options __options,
481 : recursive_directory_iterator(__p, __options, &__ec) { }
483 recursive_directory_iterator(
const path& __p, error_code& __ec)
484 : recursive_directory_iterator(__p, directory_options::none, &__ec) { }
486 recursive_directory_iterator(
487 const recursive_directory_iterator&) =
default;
489 recursive_directory_iterator(recursive_directory_iterator&&) =
default;
491 ~recursive_directory_iterator();
494 directory_options options() const noexcept;
495 int depth() const noexcept;
496 bool recursion_pending() const noexcept;
498 const directory_entry& operator*() const noexcept;
499 const directory_entry* operator->() const noexcept {
return &**
this; }
502 recursive_directory_iterator&
503 operator=(
const recursive_directory_iterator& __rhs) noexcept;
504 recursive_directory_iterator&
505 operator=(recursive_directory_iterator&& __rhs) noexcept;
507 recursive_directory_iterator& operator++();
508 recursive_directory_iterator& increment(error_code& __ec);
510 __directory_iterator_proxy operator++(
int)
512 __directory_iterator_proxy __pr{**
this};
518 void pop(error_code&);
520 void disable_recursion_pending() noexcept;
523 recursive_directory_iterator(const path&, directory_options, error_code*);
526 operator==(const recursive_directory_iterator& __lhs,
527 const recursive_directory_iterator& __rhs) noexcept
529 return !__rhs._M_dirs.owner_before(__lhs._M_dirs)
530 && !__lhs._M_dirs.owner_before(__rhs._M_dirs);
534 operator!=(
const recursive_directory_iterator& __lhs,
535 const recursive_directory_iterator& __rhs) noexcept
536 {
return !(__lhs == __rhs); }
539 std::__shared_ptr<_Dir_stack> _M_dirs;
548 inline recursive_directory_iterator
549 begin(recursive_directory_iterator __iter) noexcept
553 inline recursive_directory_iterator
554 end(recursive_directory_iterator) noexcept
555 {
return recursive_directory_iterator(); }
558 _GLIBCXX_END_NAMESPACE_CXX11
566 extern template class
567 __shared_ptr<filesystem::_Dir>;
568 extern template class
569 __shared_ptr<filesystem::recursive_directory_iterator::_Dir_stack>;
571 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
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.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.