10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 9bdd1243dSDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_FILESYSTEM 110b57cec5SDimitry Andric#define _LIBCPP_FILESYSTEM 1281ad6265SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric filesystem synopsis 150b57cec5SDimitry Andric 16349cc55cSDimitry Andric namespace std::filesystem { 170b57cec5SDimitry Andric 18bdd1243dSDimitry Andric // `class path` from http://eel.is/c++draft/fs.class.path.general#6 19bdd1243dSDimitry Andric class path { 20bdd1243dSDimitry Andric public: 21bdd1243dSDimitry Andric using value_type = see below; 22bdd1243dSDimitry Andric using string_type = basic_string<value_type>; 23bdd1243dSDimitry Andric static constexpr value_type preferred_separator = see below; 240b57cec5SDimitry Andric 25bdd1243dSDimitry Andric enum format; 260b57cec5SDimitry Andric 27bdd1243dSDimitry Andric path() noexcept; 28bdd1243dSDimitry Andric path(const path& p); 29bdd1243dSDimitry Andric path(path&& p) noexcept; 30bdd1243dSDimitry Andric path(string_type&& source, format fmt = auto_format); 31bdd1243dSDimitry Andric template<class Source> 32bdd1243dSDimitry Andric path(const Source& source, format fmt = auto_format); 33bdd1243dSDimitry Andric template<class InputIterator> 34bdd1243dSDimitry Andric path(InputIterator first, InputIterator last, format fmt = auto_format); 35bdd1243dSDimitry Andric template<class Source> 36bdd1243dSDimitry Andric path(const Source& source, const locale& loc, format fmt = auto_format); 37bdd1243dSDimitry Andric template<class InputIterator> 38bdd1243dSDimitry Andric path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format); 39bdd1243dSDimitry Andric ~path(); 400b57cec5SDimitry Andric 41bdd1243dSDimitry Andric path& operator=(const path& p); 42bdd1243dSDimitry Andric path& operator=(path&& p) noexcept; 43bdd1243dSDimitry Andric path& operator=(string_type&& source); 44bdd1243dSDimitry Andric path& assign(string_type&& source); 45bdd1243dSDimitry Andric template<class Source> 46bdd1243dSDimitry Andric path& operator=(const Source& source); 47bdd1243dSDimitry Andric template<class Source> 48bdd1243dSDimitry Andric path& assign(const Source& source); 49bdd1243dSDimitry Andric template<class InputIterator> 50bdd1243dSDimitry Andric path& assign(InputIterator first, InputIterator last); 510b57cec5SDimitry Andric 52bdd1243dSDimitry Andric path& operator/=(const path& p); 53bdd1243dSDimitry Andric template<class Source> 54bdd1243dSDimitry Andric path& operator/=(const Source& source); 55bdd1243dSDimitry Andric template<class Source> 56bdd1243dSDimitry Andric path& append(const Source& source); 57bdd1243dSDimitry Andric template<class InputIterator> 58bdd1243dSDimitry Andric path& append(InputIterator first, InputIterator last); 59bdd1243dSDimitry Andric 60bdd1243dSDimitry Andric path& operator+=(const path& x); 61bdd1243dSDimitry Andric path& operator+=(const string_type& x); 62bdd1243dSDimitry Andric path& operator+=(basic_string_view<value_type> x); 63bdd1243dSDimitry Andric path& operator+=(const value_type* x); 64bdd1243dSDimitry Andric path& operator+=(value_type x); 65bdd1243dSDimitry Andric template<class Source> 66bdd1243dSDimitry Andric path& operator+=(const Source& x); 67bdd1243dSDimitry Andric template<class EcharT> 68bdd1243dSDimitry Andric path& operator+=(EcharT x); 69bdd1243dSDimitry Andric template<class Source> 70bdd1243dSDimitry Andric path& concat(const Source& x); 71bdd1243dSDimitry Andric template<class InputIterator> 72bdd1243dSDimitry Andric path& concat(InputIterator first, InputIterator last); 73bdd1243dSDimitry Andric 74bdd1243dSDimitry Andric void clear() noexcept; 75bdd1243dSDimitry Andric path& make_preferred(); 76bdd1243dSDimitry Andric path& remove_filename(); 77bdd1243dSDimitry Andric path& replace_filename(const path& replacement); 78bdd1243dSDimitry Andric path& replace_extension(const path& replacement = path()); 79bdd1243dSDimitry Andric void swap(path& rhs) noexcept; 80bdd1243dSDimitry Andric 81bdd1243dSDimitry Andric friend bool operator==(const path& lhs, const path& rhs) noexcept; 82bdd1243dSDimitry Andric friend bool operator!=(const path& lhs, const path& rhs) noexcept; // removed in C++20 83bdd1243dSDimitry Andric friend bool operator< (const path& lhs, const path& rhs) noexcept; // removed in C++20 84bdd1243dSDimitry Andric friend bool operator<=(const path& lhs, const path& rhs) noexcept; // removed in C++20 85bdd1243dSDimitry Andric friend bool operator> (const path& lhs, const path& rhs) noexcept; // removed in C++20 86bdd1243dSDimitry Andric friend bool operator>=(const path& lhs, const path& rhs) noexcept; // removed in C++20 87bdd1243dSDimitry Andric friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept; // C++20 88bdd1243dSDimitry Andric 89bdd1243dSDimitry Andric friend path operator/(const path& lhs, const path& rhs); 90bdd1243dSDimitry Andric 91bdd1243dSDimitry Andric const string_type& native() const noexcept; 92bdd1243dSDimitry Andric const value_type* c_str() const noexcept; 93bdd1243dSDimitry Andric operator string_type() const; 94bdd1243dSDimitry Andric 95bdd1243dSDimitry Andric template<class EcharT, class traits = char_traits<EcharT>, 96bdd1243dSDimitry Andric class Allocator = allocator<EcharT>> 97bdd1243dSDimitry Andric basic_string<EcharT, traits, Allocator> 98bdd1243dSDimitry Andric string(const Allocator& a = Allocator()) const; 99bdd1243dSDimitry Andric std::string string() const; 100bdd1243dSDimitry Andric std::wstring wstring() const; 101bdd1243dSDimitry Andric std::u8string u8string() const; 102bdd1243dSDimitry Andric std::u16string u16string() const; 103bdd1243dSDimitry Andric std::u32string u32string() const; 104bdd1243dSDimitry Andric 105bdd1243dSDimitry Andric template<class EcharT, class traits = char_traits<EcharT>, 106bdd1243dSDimitry Andric class Allocator = allocator<EcharT>> 107bdd1243dSDimitry Andric basic_string<EcharT, traits, Allocator> 108bdd1243dSDimitry Andric generic_string(const Allocator& a = Allocator()) const; 109bdd1243dSDimitry Andric std::string generic_string() const; 110bdd1243dSDimitry Andric std::wstring generic_wstring() const; 111bdd1243dSDimitry Andric std::u8string generic_u8string() const; 112bdd1243dSDimitry Andric std::u16string generic_u16string() const; 113bdd1243dSDimitry Andric std::u32string generic_u32string() const; 114bdd1243dSDimitry Andric 115bdd1243dSDimitry Andric int compare(const path& p) const noexcept; 116bdd1243dSDimitry Andric int compare(const string_type& s) const; 117bdd1243dSDimitry Andric int compare(basic_string_view<value_type> s) const; 118bdd1243dSDimitry Andric int compare(const value_type* s) const; 119bdd1243dSDimitry Andric 120bdd1243dSDimitry Andric path root_name() const; 121bdd1243dSDimitry Andric path root_directory() const; 122bdd1243dSDimitry Andric path root_path() const; 123bdd1243dSDimitry Andric path relative_path() const; 124bdd1243dSDimitry Andric path parent_path() const; 125bdd1243dSDimitry Andric path filename() const; 126bdd1243dSDimitry Andric path stem() const; 127bdd1243dSDimitry Andric path extension() const; 128bdd1243dSDimitry Andric 129bdd1243dSDimitry Andric [[nodiscard]] bool empty() const noexcept; 130bdd1243dSDimitry Andric bool has_root_name() const; 131bdd1243dSDimitry Andric bool has_root_directory() const; 132bdd1243dSDimitry Andric bool has_root_path() const; 133bdd1243dSDimitry Andric bool has_relative_path() const; 134bdd1243dSDimitry Andric bool has_parent_path() const; 135bdd1243dSDimitry Andric bool has_filename() const; 136bdd1243dSDimitry Andric bool has_stem() const; 137bdd1243dSDimitry Andric bool has_extension() const; 138bdd1243dSDimitry Andric bool is_absolute() const; 139bdd1243dSDimitry Andric bool is_relative() const; 140bdd1243dSDimitry Andric 141bdd1243dSDimitry Andric path lexically_normal() const; 142bdd1243dSDimitry Andric path lexically_relative(const path& base) const; 143bdd1243dSDimitry Andric path lexically_proximate(const path& base) const; 144bdd1243dSDimitry Andric 145bdd1243dSDimitry Andric class iterator; 146bdd1243dSDimitry Andric using const_iterator = iterator; 147bdd1243dSDimitry Andric 148bdd1243dSDimitry Andric iterator begin() const; 149bdd1243dSDimitry Andric iterator end() const; 150bdd1243dSDimitry Andric 1510b57cec5SDimitry Andric template<class charT, class traits> 1520b57cec5SDimitry Andric friend basic_ostream<charT, traits>& 1530b57cec5SDimitry Andric operator<<(basic_ostream<charT, traits>& os, const path& p); 1540b57cec5SDimitry Andric template<class charT, class traits> 1550b57cec5SDimitry Andric friend basic_istream<charT, traits>& 1560b57cec5SDimitry Andric operator>>(basic_istream<charT, traits>& is, path& p); 157bdd1243dSDimitry Andric }; 158bdd1243dSDimitry Andric 159bdd1243dSDimitry Andric void swap(path& lhs, path& rhs) noexcept; 160bdd1243dSDimitry Andric size_t hash_value(const path& p) noexcept; 1610b57cec5SDimitry Andric 16206c3fb27SDimitry Andric // [fs.path.hash], hash support 16306c3fb27SDimitry Andric template<> struct hash<filesystem::path>; 16406c3fb27SDimitry Andric 1650b57cec5SDimitry Andric template <class Source> 1660b57cec5SDimitry Andric path u8path(const Source& source); 1670b57cec5SDimitry Andric template <class InputIterator> 1680b57cec5SDimitry Andric path u8path(InputIterator first, InputIterator last); 1690b57cec5SDimitry Andric 1700b57cec5SDimitry Andric class filesystem_error; 171bdd1243dSDimitry Andric 172bdd1243dSDimitry Andric class directory_entry { 173bdd1243dSDimitry Andric public: 174bdd1243dSDimitry Andric directory_entry() noexcept = default; 175bdd1243dSDimitry Andric directory_entry(const directory_entry&) = default; 176bdd1243dSDimitry Andric directory_entry(directory_entry&&) noexcept = default; 177bdd1243dSDimitry Andric explicit directory_entry(const filesystem::path& p); 178bdd1243dSDimitry Andric directory_entry(const filesystem::path& p, error_code& ec); 179bdd1243dSDimitry Andric ~directory_entry(); 180bdd1243dSDimitry Andric 181bdd1243dSDimitry Andric directory_entry& operator=(const directory_entry&) = default; 182bdd1243dSDimitry Andric directory_entry& operator=(directory_entry&&) noexcept = default; 183bdd1243dSDimitry Andric 184bdd1243dSDimitry Andric void assign(const filesystem::path& p); 185bdd1243dSDimitry Andric void assign(const filesystem::path& p, error_code& ec); 186bdd1243dSDimitry Andric void replace_filename(const filesystem::path& p); 187bdd1243dSDimitry Andric void replace_filename(const filesystem::path& p, error_code& ec); 188bdd1243dSDimitry Andric void refresh(); 189bdd1243dSDimitry Andric void refresh(error_code& ec) noexcept; 190bdd1243dSDimitry Andric 191bdd1243dSDimitry Andric const filesystem::path& path() const noexcept; 192bdd1243dSDimitry Andric operator const filesystem::path&() const noexcept; 193bdd1243dSDimitry Andric bool exists() const; 194bdd1243dSDimitry Andric bool exists(error_code& ec) const noexcept; 195bdd1243dSDimitry Andric bool is_block_file() const; 196bdd1243dSDimitry Andric bool is_block_file(error_code& ec) const noexcept; 197bdd1243dSDimitry Andric bool is_character_file() const; 198bdd1243dSDimitry Andric bool is_character_file(error_code& ec) const noexcept; 199bdd1243dSDimitry Andric bool is_directory() const; 200bdd1243dSDimitry Andric bool is_directory(error_code& ec) const noexcept; 201bdd1243dSDimitry Andric bool is_fifo() const; 202bdd1243dSDimitry Andric bool is_fifo(error_code& ec) const noexcept; 203bdd1243dSDimitry Andric bool is_other() const; 204bdd1243dSDimitry Andric bool is_other(error_code& ec) const noexcept; 205bdd1243dSDimitry Andric bool is_regular_file() const; 206bdd1243dSDimitry Andric bool is_regular_file(error_code& ec) const noexcept; 207bdd1243dSDimitry Andric bool is_socket() const; 208bdd1243dSDimitry Andric bool is_socket(error_code& ec) const noexcept; 209bdd1243dSDimitry Andric bool is_symlink() const; 210bdd1243dSDimitry Andric bool is_symlink(error_code& ec) const noexcept; 211bdd1243dSDimitry Andric uintmax_t file_size() const; 212bdd1243dSDimitry Andric uintmax_t file_size(error_code& ec) const noexcept; 213bdd1243dSDimitry Andric uintmax_t hard_link_count() const; 214bdd1243dSDimitry Andric uintmax_t hard_link_count(error_code& ec) const noexcept; 215bdd1243dSDimitry Andric file_time_type last_write_time() const; 216bdd1243dSDimitry Andric file_time_type last_write_time(error_code& ec) const noexcept; 217bdd1243dSDimitry Andric file_status status() const; 218bdd1243dSDimitry Andric file_status status(error_code& ec) const noexcept; 219bdd1243dSDimitry Andric file_status symlink_status() const; 220bdd1243dSDimitry Andric file_status symlink_status(error_code& ec) const noexcept; 221bdd1243dSDimitry Andric 222bdd1243dSDimitry Andric bool operator==(const directory_entry& rhs) const noexcept; 223bdd1243dSDimitry Andric bool operator!=(const directory_entry& rhs) const noexcept; // removed in C++20 224bdd1243dSDimitry Andric bool operator< (const directory_entry& rhs) const noexcept; // removed in C++20 225bdd1243dSDimitry Andric bool operator<=(const directory_entry& rhs) const noexcept; // removed in C++20 226bdd1243dSDimitry Andric bool operator> (const directory_entry& rhs) const noexcept; // removed in C++20 227bdd1243dSDimitry Andric bool operator>=(const directory_entry& rhs) const noexcept; // removed in C++20 228bdd1243dSDimitry Andric strong_ordering operator<=>(const directory_entry& rhs) const noexcept; // since C++20 229bdd1243dSDimitry Andric 230bdd1243dSDimitry Andric template<class charT, class traits> 231bdd1243dSDimitry Andric friend basic_ostream<charT, traits>& 232bdd1243dSDimitry Andric operator<<(basic_ostream<charT, traits>& os, const directory_entry& d); 233bdd1243dSDimitry Andric 234bdd1243dSDimitry Andric private: 235bdd1243dSDimitry Andric filesystem::path pathobject; // exposition only 236bdd1243dSDimitry Andric friend class directory_iterator; // exposition only 237bdd1243dSDimitry Andric }; 2380b57cec5SDimitry Andric 23906c3fb27SDimitry Andric class directory_iterator { 24006c3fb27SDimitry Andric public: 24106c3fb27SDimitry Andric using iterator_category = input_iterator_tag; 24206c3fb27SDimitry Andric using value_type = directory_entry; 24306c3fb27SDimitry Andric using difference_type = ptrdiff_t; 24406c3fb27SDimitry Andric using pointer = const directory_entry*; 24506c3fb27SDimitry Andric using reference = const directory_entry&; 24606c3fb27SDimitry Andric 24706c3fb27SDimitry Andric // [fs.dir.itr.members], member functions 24806c3fb27SDimitry Andric directory_iterator() noexcept; 24906c3fb27SDimitry Andric explicit directory_iterator(const path& p); 25006c3fb27SDimitry Andric directory_iterator(const path& p, directory_options options); 25106c3fb27SDimitry Andric directory_iterator(const path& p, error_code& ec); 25206c3fb27SDimitry Andric directory_iterator(const path& p, directory_options options, 25306c3fb27SDimitry Andric error_code& ec); 25406c3fb27SDimitry Andric directory_iterator(const directory_iterator& rhs); 25506c3fb27SDimitry Andric directory_iterator(directory_iterator&& rhs) noexcept; 25606c3fb27SDimitry Andric ~directory_iterator(); 25706c3fb27SDimitry Andric 25806c3fb27SDimitry Andric directory_iterator& operator=(const directory_iterator& rhs); 25906c3fb27SDimitry Andric directory_iterator& operator=(directory_iterator&& rhs) noexcept; 26006c3fb27SDimitry Andric 26106c3fb27SDimitry Andric const directory_entry& operator*() const; 26206c3fb27SDimitry Andric const directory_entry* operator->() const; 26306c3fb27SDimitry Andric directory_iterator& operator++(); 26406c3fb27SDimitry Andric directory_iterator& increment(error_code& ec); 26506c3fb27SDimitry Andric 26606c3fb27SDimitry Andric bool operator==(default_sentinel_t) const noexcept { // since C++20 26706c3fb27SDimitry Andric return *this == directory_iterator(); 26806c3fb27SDimitry Andric } 26906c3fb27SDimitry Andric 27006c3fb27SDimitry Andric // other members as required by [input.iterators], input iterators 27106c3fb27SDimitry Andric }; 2720b57cec5SDimitry Andric 2730b57cec5SDimitry Andric // enable directory_iterator range-based for statements 2740b57cec5SDimitry Andric directory_iterator begin(directory_iterator iter) noexcept; 275349cc55cSDimitry Andric directory_iterator end(directory_iterator) noexcept; 2760b57cec5SDimitry Andric 27706c3fb27SDimitry Andricclass recursive_directory_iterator { 27806c3fb27SDimitry Andric public: 27906c3fb27SDimitry Andric using iterator_category = input_iterator_tag; 28006c3fb27SDimitry Andric using value_type = directory_entry; 28106c3fb27SDimitry Andric using difference_type = ptrdiff_t; 28206c3fb27SDimitry Andric using pointer = const directory_entry*; 28306c3fb27SDimitry Andric using reference = const directory_entry&; 28406c3fb27SDimitry Andric 28506c3fb27SDimitry Andric // [fs.rec.dir.itr.members], constructors and destructor 28606c3fb27SDimitry Andric recursive_directory_iterator() noexcept; 28706c3fb27SDimitry Andric explicit recursive_directory_iterator(const path& p); 28806c3fb27SDimitry Andric recursive_directory_iterator(const path& p, directory_options options); 28906c3fb27SDimitry Andric recursive_directory_iterator(const path& p, directory_options options, 29006c3fb27SDimitry Andric error_code& ec); 29106c3fb27SDimitry Andric recursive_directory_iterator(const path& p, error_code& ec); 29206c3fb27SDimitry Andric recursive_directory_iterator(const recursive_directory_iterator& rhs); 29306c3fb27SDimitry Andric recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; 29406c3fb27SDimitry Andric ~recursive_directory_iterator(); 29506c3fb27SDimitry Andric 29606c3fb27SDimitry Andric // [fs.rec.dir.itr.members], observers 29706c3fb27SDimitry Andric directory_options options() const; 29806c3fb27SDimitry Andric int depth() const; 29906c3fb27SDimitry Andric bool recursion_pending() const; 30006c3fb27SDimitry Andric 30106c3fb27SDimitry Andric const directory_entry& operator*() const; 30206c3fb27SDimitry Andric const directory_entry* operator->() const; 30306c3fb27SDimitry Andric 30406c3fb27SDimitry Andric // [fs.rec.dir.itr.members], modifiers 30506c3fb27SDimitry Andric recursive_directory_iterator& 30606c3fb27SDimitry Andric operator=(const recursive_directory_iterator& rhs); 30706c3fb27SDimitry Andric recursive_directory_iterator& 30806c3fb27SDimitry Andric operator=(recursive_directory_iterator&& rhs) noexcept; 30906c3fb27SDimitry Andric 31006c3fb27SDimitry Andric recursive_directory_iterator& operator++(); 31106c3fb27SDimitry Andric recursive_directory_iterator& increment(error_code& ec); 31206c3fb27SDimitry Andric 31306c3fb27SDimitry Andric void pop(); 31406c3fb27SDimitry Andric void pop(error_code& ec); 31506c3fb27SDimitry Andric void disable_recursion_pending(); 31606c3fb27SDimitry Andric 31706c3fb27SDimitry Andric bool operator==(default_sentinel_t) const noexcept { // since C++20 31806c3fb27SDimitry Andric return *this == recursive_directory_iterator(); 31906c3fb27SDimitry Andric } 32006c3fb27SDimitry Andric 32106c3fb27SDimitry Andric // other members as required by [input.iterators], input iterators 32206c3fb27SDimitry Andric }; 3230b57cec5SDimitry Andric 3240b57cec5SDimitry Andric // enable recursive_directory_iterator range-based for statements 3250b57cec5SDimitry Andric recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; 326349cc55cSDimitry Andric recursive_directory_iterator end(recursive_directory_iterator) noexcept; 3270b57cec5SDimitry Andric 32806c3fb27SDimitry Andric class file_status { 32906c3fb27SDimitry Andric public: 33006c3fb27SDimitry Andric // [fs.file.status.cons], constructors and destructor 33106c3fb27SDimitry Andric file_status() noexcept : file_status(file_type::none) {} 33206c3fb27SDimitry Andric explicit file_status(file_type ft, 33306c3fb27SDimitry Andric perms prms = perms::unknown) noexcept; 33406c3fb27SDimitry Andric file_status(const file_status&) noexcept = default; 33506c3fb27SDimitry Andric file_status(file_status&&) noexcept = default; 33606c3fb27SDimitry Andric ~file_status(); 33706c3fb27SDimitry Andric 33806c3fb27SDimitry Andric // assignments 33906c3fb27SDimitry Andric file_status& operator=(const file_status&) noexcept = default; 34006c3fb27SDimitry Andric file_status& operator=(file_status&&) noexcept = default; 34106c3fb27SDimitry Andric 34206c3fb27SDimitry Andric // [fs.file.status.mods], modifiers 34306c3fb27SDimitry Andric void type(file_type ft) noexcept; 34406c3fb27SDimitry Andric void permissions(perms prms) noexcept; 34506c3fb27SDimitry Andric 34606c3fb27SDimitry Andric // [fs.file.status.obs], observers 34706c3fb27SDimitry Andric file_type type() const noexcept; 34806c3fb27SDimitry Andric perms permissions() const noexcept; 34906c3fb27SDimitry Andric 35006c3fb27SDimitry Andric friend bool operator==(const file_status& lhs, const file_status& rhs) noexcept 35106c3fb27SDimitry Andric { return lhs.type() == rhs.type() && lhs.permissions() == rhs.permissions(); } // C++20 35206c3fb27SDimitry Andric }; 3530b57cec5SDimitry Andric 3540b57cec5SDimitry Andric struct space_info 3550b57cec5SDimitry Andric { 3560b57cec5SDimitry Andric uintmax_t capacity; 3570b57cec5SDimitry Andric uintmax_t free; 3580b57cec5SDimitry Andric uintmax_t available; 359bdd1243dSDimitry Andric 360bdd1243dSDimitry Andric friend bool operator==(const space_info&, const space_info&) = default; // C++20 3610b57cec5SDimitry Andric }; 3620b57cec5SDimitry Andric 3630b57cec5SDimitry Andric enum class file_type; 3640b57cec5SDimitry Andric enum class perms; 3650b57cec5SDimitry Andric enum class perm_options; 3660b57cec5SDimitry Andric enum class copy_options; 3670b57cec5SDimitry Andric enum class directory_options; 3680b57cec5SDimitry Andric 3690b57cec5SDimitry Andric typedef chrono::time_point<trivial-clock> file_time_type; 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andric // operational functions 3720b57cec5SDimitry Andric 3730b57cec5SDimitry Andric path absolute(const path& p); 3740b57cec5SDimitry Andric path absolute(const path& p, error_code &ec); 3750b57cec5SDimitry Andric 3760b57cec5SDimitry Andric path canonical(const path& p); 3770b57cec5SDimitry Andric path canonical(const path& p, error_code& ec); 3780b57cec5SDimitry Andric 3790b57cec5SDimitry Andric void copy(const path& from, const path& to); 3800b57cec5SDimitry Andric void copy(const path& from, const path& to, error_code& ec); 3810b57cec5SDimitry Andric void copy(const path& from, const path& to, copy_options options); 3820b57cec5SDimitry Andric void copy(const path& from, const path& to, copy_options options, 3830b57cec5SDimitry Andric error_code& ec); 3840b57cec5SDimitry Andric 3850b57cec5SDimitry Andric bool copy_file(const path& from, const path& to); 3860b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, error_code& ec); 3870b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, copy_options option); 3880b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, copy_options option, 3890b57cec5SDimitry Andric error_code& ec); 3900b57cec5SDimitry Andric 3910b57cec5SDimitry Andric void copy_symlink(const path& existing_symlink, const path& new_symlink); 3920b57cec5SDimitry Andric void copy_symlink(const path& existing_symlink, const path& new_symlink, 3930b57cec5SDimitry Andric error_code& ec) noexcept; 3940b57cec5SDimitry Andric 3950b57cec5SDimitry Andric bool create_directories(const path& p); 3960b57cec5SDimitry Andric bool create_directories(const path& p, error_code& ec); 3970b57cec5SDimitry Andric 3980b57cec5SDimitry Andric bool create_directory(const path& p); 3990b57cec5SDimitry Andric bool create_directory(const path& p, error_code& ec) noexcept; 4000b57cec5SDimitry Andric 4010b57cec5SDimitry Andric bool create_directory(const path& p, const path& attributes); 4020b57cec5SDimitry Andric bool create_directory(const path& p, const path& attributes, 4030b57cec5SDimitry Andric error_code& ec) noexcept; 4040b57cec5SDimitry Andric 4050b57cec5SDimitry Andric void create_directory_symlink(const path& to, const path& new_symlink); 4060b57cec5SDimitry Andric void create_directory_symlink(const path& to, const path& new_symlink, 4070b57cec5SDimitry Andric error_code& ec) noexcept; 4080b57cec5SDimitry Andric 4090b57cec5SDimitry Andric void create_hard_link(const path& to, const path& new_hard_link); 4100b57cec5SDimitry Andric void create_hard_link(const path& to, const path& new_hard_link, 4110b57cec5SDimitry Andric error_code& ec) noexcept; 4120b57cec5SDimitry Andric 4130b57cec5SDimitry Andric void create_symlink(const path& to, const path& new_symlink); 4140b57cec5SDimitry Andric void create_symlink(const path& to, const path& new_symlink, 4150b57cec5SDimitry Andric error_code& ec) noexcept; 4160b57cec5SDimitry Andric 4170b57cec5SDimitry Andric path current_path(); 4180b57cec5SDimitry Andric path current_path(error_code& ec); 4190b57cec5SDimitry Andric void current_path(const path& p); 4200b57cec5SDimitry Andric void current_path(const path& p, error_code& ec) noexcept; 4210b57cec5SDimitry Andric 4220b57cec5SDimitry Andric bool exists(file_status s) noexcept; 4230b57cec5SDimitry Andric bool exists(const path& p); 4240b57cec5SDimitry Andric bool exists(const path& p, error_code& ec) noexcept; 4250b57cec5SDimitry Andric 4260b57cec5SDimitry Andric bool equivalent(const path& p1, const path& p2); 4270b57cec5SDimitry Andric bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; 4280b57cec5SDimitry Andric 4290b57cec5SDimitry Andric uintmax_t file_size(const path& p); 4300b57cec5SDimitry Andric uintmax_t file_size(const path& p, error_code& ec) noexcept; 4310b57cec5SDimitry Andric 4320b57cec5SDimitry Andric uintmax_t hard_link_count(const path& p); 4330b57cec5SDimitry Andric uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; 4340b57cec5SDimitry Andric 4350b57cec5SDimitry Andric bool is_block_file(file_status s) noexcept; 4360b57cec5SDimitry Andric bool is_block_file(const path& p); 4370b57cec5SDimitry Andric bool is_block_file(const path& p, error_code& ec) noexcept; 4380b57cec5SDimitry Andric 4390b57cec5SDimitry Andric bool is_character_file(file_status s) noexcept; 4400b57cec5SDimitry Andric bool is_character_file(const path& p); 4410b57cec5SDimitry Andric bool is_character_file(const path& p, error_code& ec) noexcept; 4420b57cec5SDimitry Andric 4430b57cec5SDimitry Andric bool is_directory(file_status s) noexcept; 4440b57cec5SDimitry Andric bool is_directory(const path& p); 4450b57cec5SDimitry Andric bool is_directory(const path& p, error_code& ec) noexcept; 4460b57cec5SDimitry Andric 4470b57cec5SDimitry Andric bool is_empty(const path& p); 4480b57cec5SDimitry Andric bool is_empty(const path& p, error_code& ec) noexcept; 4490b57cec5SDimitry Andric 4500b57cec5SDimitry Andric bool is_fifo(file_status s) noexcept; 4510b57cec5SDimitry Andric bool is_fifo(const path& p); 4520b57cec5SDimitry Andric bool is_fifo(const path& p, error_code& ec) noexcept; 4530b57cec5SDimitry Andric 4540b57cec5SDimitry Andric bool is_other(file_status s) noexcept; 4550b57cec5SDimitry Andric bool is_other(const path& p); 4560b57cec5SDimitry Andric bool is_other(const path& p, error_code& ec) noexcept; 4570b57cec5SDimitry Andric 4580b57cec5SDimitry Andric bool is_regular_file(file_status s) noexcept; 4590b57cec5SDimitry Andric bool is_regular_file(const path& p); 4600b57cec5SDimitry Andric bool is_regular_file(const path& p, error_code& ec) noexcept; 4610b57cec5SDimitry Andric 4620b57cec5SDimitry Andric bool is_socket(file_status s) noexcept; 4630b57cec5SDimitry Andric bool is_socket(const path& p); 4640b57cec5SDimitry Andric bool is_socket(const path& p, error_code& ec) noexcept; 4650b57cec5SDimitry Andric 4660b57cec5SDimitry Andric bool is_symlink(file_status s) noexcept; 4670b57cec5SDimitry Andric bool is_symlink(const path& p); 4680b57cec5SDimitry Andric bool is_symlink(const path& p, error_code& ec) noexcept; 4690b57cec5SDimitry Andric 4700b57cec5SDimitry Andric file_time_type last_write_time(const path& p); 4710b57cec5SDimitry Andric file_time_type last_write_time(const path& p, error_code& ec) noexcept; 4720b57cec5SDimitry Andric void last_write_time(const path& p, file_time_type new_time); 4730b57cec5SDimitry Andric void last_write_time(const path& p, file_time_type new_time, 4740b57cec5SDimitry Andric error_code& ec) noexcept; 4750b57cec5SDimitry Andric 4760b57cec5SDimitry Andric void permissions(const path& p, perms prms, 4770b57cec5SDimitry Andric perm_options opts=perm_options::replace); 4780b57cec5SDimitry Andric void permissions(const path& p, perms prms, error_code& ec) noexcept; 4790b57cec5SDimitry Andric void permissions(const path& p, perms prms, perm_options opts, 4800b57cec5SDimitry Andric error_code& ec); 4810b57cec5SDimitry Andric 4820b57cec5SDimitry Andric path proximate(const path& p, error_code& ec); 4830b57cec5SDimitry Andric path proximate(const path& p, const path& base = current_path()); 4840b57cec5SDimitry Andric path proximate(const path& p, const path& base, error_code &ec); 4850b57cec5SDimitry Andric 4860b57cec5SDimitry Andric path read_symlink(const path& p); 4870b57cec5SDimitry Andric path read_symlink(const path& p, error_code& ec); 4880b57cec5SDimitry Andric 4890b57cec5SDimitry Andric path relative(const path& p, error_code& ec); 4900b57cec5SDimitry Andric path relative(const path& p, const path& base=current_path()); 4910b57cec5SDimitry Andric path relative(const path& p, const path& base, error_code& ec); 4920b57cec5SDimitry Andric 4930b57cec5SDimitry Andric bool remove(const path& p); 4940b57cec5SDimitry Andric bool remove(const path& p, error_code& ec) noexcept; 4950b57cec5SDimitry Andric 4960b57cec5SDimitry Andric uintmax_t remove_all(const path& p); 4970b57cec5SDimitry Andric uintmax_t remove_all(const path& p, error_code& ec); 4980b57cec5SDimitry Andric 4990b57cec5SDimitry Andric void rename(const path& from, const path& to); 5000b57cec5SDimitry Andric void rename(const path& from, const path& to, error_code& ec) noexcept; 5010b57cec5SDimitry Andric 5020b57cec5SDimitry Andric void resize_file(const path& p, uintmax_t size); 5030b57cec5SDimitry Andric void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; 5040b57cec5SDimitry Andric 5050b57cec5SDimitry Andric space_info space(const path& p); 5060b57cec5SDimitry Andric space_info space(const path& p, error_code& ec) noexcept; 5070b57cec5SDimitry Andric 5080b57cec5SDimitry Andric file_status status(const path& p); 5090b57cec5SDimitry Andric file_status status(const path& p, error_code& ec) noexcept; 5100b57cec5SDimitry Andric 5110b57cec5SDimitry Andric bool status_known(file_status s) noexcept; 5120b57cec5SDimitry Andric 5130b57cec5SDimitry Andric file_status symlink_status(const path& p); 5140b57cec5SDimitry Andric file_status symlink_status(const path& p, error_code& ec) noexcept; 5150b57cec5SDimitry Andric 5160b57cec5SDimitry Andric path temp_directory_path(); 5170b57cec5SDimitry Andric path temp_directory_path(error_code& ec); 5180b57cec5SDimitry Andric 5190b57cec5SDimitry Andric path weakly_canonical(path const& p); 5200b57cec5SDimitry Andric path weakly_canonical(path const& p, error_code& ec); 5210b57cec5SDimitry Andric 522349cc55cSDimitry Andric} // namespace std::filesystem 5230b57cec5SDimitry Andric 524349cc55cSDimitry Andrictemplate <> 525349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; 526349cc55cSDimitry Andrictemplate <> 527349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; 528349cc55cSDimitry Andric 529349cc55cSDimitry Andrictemplate <> 530349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; 531349cc55cSDimitry Andrictemplate <> 532349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; 5330b57cec5SDimitry Andric 5340b57cec5SDimitry Andric*/ 5350b57cec5SDimitry Andric 536fe6060f1SDimitry Andric#include <__config> 537*0fca6ea1SDimitry Andric 538*0fca6ea1SDimitry Andric#if _LIBCPP_STD_VER >= 17 5390eae32dcSDimitry Andric# include <__filesystem/copy_options.h> 5400eae32dcSDimitry Andric# include <__filesystem/directory_entry.h> 5410eae32dcSDimitry Andric# include <__filesystem/directory_iterator.h> 5420eae32dcSDimitry Andric# include <__filesystem/directory_options.h> 5430eae32dcSDimitry Andric# include <__filesystem/file_status.h> 5440eae32dcSDimitry Andric# include <__filesystem/file_time_type.h> 5450eae32dcSDimitry Andric# include <__filesystem/file_type.h> 5460eae32dcSDimitry Andric# include <__filesystem/filesystem_error.h> 5470eae32dcSDimitry Andric# include <__filesystem/operations.h> 5480eae32dcSDimitry Andric# include <__filesystem/path.h> 54904eeddc0SDimitry Andric# include <__filesystem/path_iterator.h> 5500eae32dcSDimitry Andric# include <__filesystem/perm_options.h> 5510eae32dcSDimitry Andric# include <__filesystem/perms.h> 5520eae32dcSDimitry Andric# include <__filesystem/recursive_directory_iterator.h> 5530eae32dcSDimitry Andric# include <__filesystem/space_info.h> 5540eae32dcSDimitry Andric# include <__filesystem/u8path.h> 555*0fca6ea1SDimitry Andric#endif 556*0fca6ea1SDimitry Andric 5570b57cec5SDimitry Andric#include <version> 5580b57cec5SDimitry Andric 55981ad6265SDimitry Andric// standard-mandated includes 560bdd1243dSDimitry Andric 561bdd1243dSDimitry Andric// [fs.filesystem.syn] 56281ad6265SDimitry Andric#include <compare> 56381ad6265SDimitry Andric 5640b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5650b57cec5SDimitry Andric# pragma GCC system_header 5660b57cec5SDimitry Andric#endif 5670b57cec5SDimitry Andric 568bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 569bdd1243dSDimitry Andric# include <concepts> 57006c3fb27SDimitry Andric# include <cstdlib> 571*0fca6ea1SDimitry Andric# include <cstring> 5725f757f3fSDimitry Andric# include <iosfwd> 5735f757f3fSDimitry Andric# include <new> 57406c3fb27SDimitry Andric# include <system_error> 575bdd1243dSDimitry Andric#endif 576bdd1243dSDimitry Andric 5770b57cec5SDimitry Andric#endif // _LIBCPP_FILESYSTEM 578