1998a5c88SEric Fiselier// -*- C++ -*- 2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===// 3998a5c88SEric Fiselier// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7998a5c88SEric Fiselier// 8998a5c88SEric Fiselier//===----------------------------------------------------------------------===// 9480cd780SLouis Dionne 10998a5c88SEric Fiselier#ifndef _LIBCPP_FILESYSTEM 11998a5c88SEric Fiselier#define _LIBCPP_FILESYSTEM 12385cc25aSLouis Dionne 13998a5c88SEric Fiselier/* 14998a5c88SEric Fiselier filesystem synopsis 15998a5c88SEric Fiselier 161fa27f2aSJoe Loser namespace std::filesystem { 17998a5c88SEric Fiselier 18b3ab3becSAdrian Vogelsgesang // `class path` from http://eel.is/c++draft/fs.class.path.general#6 19b3ab3becSAdrian Vogelsgesang class path { 20b3ab3becSAdrian Vogelsgesang public: 21b3ab3becSAdrian Vogelsgesang using value_type = see below; 22b3ab3becSAdrian Vogelsgesang using string_type = basic_string<value_type>; 23b3ab3becSAdrian Vogelsgesang static constexpr value_type preferred_separator = see below; 24998a5c88SEric Fiselier 25b3ab3becSAdrian Vogelsgesang enum format; 26998a5c88SEric Fiselier 27b3ab3becSAdrian Vogelsgesang path() noexcept; 28b3ab3becSAdrian Vogelsgesang path(const path& p); 29b3ab3becSAdrian Vogelsgesang path(path&& p) noexcept; 30b3ab3becSAdrian Vogelsgesang path(string_type&& source, format fmt = auto_format); 31b3ab3becSAdrian Vogelsgesang template<class Source> 32b3ab3becSAdrian Vogelsgesang path(const Source& source, format fmt = auto_format); 33b3ab3becSAdrian Vogelsgesang template<class InputIterator> 34b3ab3becSAdrian Vogelsgesang path(InputIterator first, InputIterator last, format fmt = auto_format); 35b3ab3becSAdrian Vogelsgesang template<class Source> 36b3ab3becSAdrian Vogelsgesang path(const Source& source, const locale& loc, format fmt = auto_format); 37b3ab3becSAdrian Vogelsgesang template<class InputIterator> 38b3ab3becSAdrian Vogelsgesang path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format); 39b3ab3becSAdrian Vogelsgesang ~path(); 40998a5c88SEric Fiselier 41b3ab3becSAdrian Vogelsgesang path& operator=(const path& p); 42b3ab3becSAdrian Vogelsgesang path& operator=(path&& p) noexcept; 43b3ab3becSAdrian Vogelsgesang path& operator=(string_type&& source); 44b3ab3becSAdrian Vogelsgesang path& assign(string_type&& source); 45b3ab3becSAdrian Vogelsgesang template<class Source> 46b3ab3becSAdrian Vogelsgesang path& operator=(const Source& source); 47b3ab3becSAdrian Vogelsgesang template<class Source> 48b3ab3becSAdrian Vogelsgesang path& assign(const Source& source); 49b3ab3becSAdrian Vogelsgesang template<class InputIterator> 50b3ab3becSAdrian Vogelsgesang path& assign(InputIterator first, InputIterator last); 51998a5c88SEric Fiselier 52b3ab3becSAdrian Vogelsgesang path& operator/=(const path& p); 53b3ab3becSAdrian Vogelsgesang template<class Source> 54b3ab3becSAdrian Vogelsgesang path& operator/=(const Source& source); 55b3ab3becSAdrian Vogelsgesang template<class Source> 56b3ab3becSAdrian Vogelsgesang path& append(const Source& source); 57b3ab3becSAdrian Vogelsgesang template<class InputIterator> 58b3ab3becSAdrian Vogelsgesang path& append(InputIterator first, InputIterator last); 59b3ab3becSAdrian Vogelsgesang 60b3ab3becSAdrian Vogelsgesang path& operator+=(const path& x); 61b3ab3becSAdrian Vogelsgesang path& operator+=(const string_type& x); 62b3ab3becSAdrian Vogelsgesang path& operator+=(basic_string_view<value_type> x); 63b3ab3becSAdrian Vogelsgesang path& operator+=(const value_type* x); 64b3ab3becSAdrian Vogelsgesang path& operator+=(value_type x); 65b3ab3becSAdrian Vogelsgesang template<class Source> 66b3ab3becSAdrian Vogelsgesang path& operator+=(const Source& x); 67b3ab3becSAdrian Vogelsgesang template<class EcharT> 68b3ab3becSAdrian Vogelsgesang path& operator+=(EcharT x); 69b3ab3becSAdrian Vogelsgesang template<class Source> 70b3ab3becSAdrian Vogelsgesang path& concat(const Source& x); 71b3ab3becSAdrian Vogelsgesang template<class InputIterator> 72b3ab3becSAdrian Vogelsgesang path& concat(InputIterator first, InputIterator last); 73b3ab3becSAdrian Vogelsgesang 74b3ab3becSAdrian Vogelsgesang void clear() noexcept; 75b3ab3becSAdrian Vogelsgesang path& make_preferred(); 76b3ab3becSAdrian Vogelsgesang path& remove_filename(); 77b3ab3becSAdrian Vogelsgesang path& replace_filename(const path& replacement); 78b3ab3becSAdrian Vogelsgesang path& replace_extension(const path& replacement = path()); 79b3ab3becSAdrian Vogelsgesang void swap(path& rhs) noexcept; 80b3ab3becSAdrian Vogelsgesang 81b3ab3becSAdrian Vogelsgesang friend bool operator==(const path& lhs, const path& rhs) noexcept; 82b3ab3becSAdrian Vogelsgesang friend bool operator!=(const path& lhs, const path& rhs) noexcept; // removed in C++20 83b3ab3becSAdrian Vogelsgesang friend bool operator< (const path& lhs, const path& rhs) noexcept; // removed in C++20 84b3ab3becSAdrian Vogelsgesang friend bool operator<=(const path& lhs, const path& rhs) noexcept; // removed in C++20 85b3ab3becSAdrian Vogelsgesang friend bool operator> (const path& lhs, const path& rhs) noexcept; // removed in C++20 86b3ab3becSAdrian Vogelsgesang friend bool operator>=(const path& lhs, const path& rhs) noexcept; // removed in C++20 87b3ab3becSAdrian Vogelsgesang friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept; // C++20 88b3ab3becSAdrian Vogelsgesang 89b3ab3becSAdrian Vogelsgesang friend path operator/(const path& lhs, const path& rhs); 90b3ab3becSAdrian Vogelsgesang 91b3ab3becSAdrian Vogelsgesang const string_type& native() const noexcept; 92b3ab3becSAdrian Vogelsgesang const value_type* c_str() const noexcept; 93b3ab3becSAdrian Vogelsgesang operator string_type() const; 94b3ab3becSAdrian Vogelsgesang 95b3ab3becSAdrian Vogelsgesang template<class EcharT, class traits = char_traits<EcharT>, 96b3ab3becSAdrian Vogelsgesang class Allocator = allocator<EcharT>> 97b3ab3becSAdrian Vogelsgesang basic_string<EcharT, traits, Allocator> 98b3ab3becSAdrian Vogelsgesang string(const Allocator& a = Allocator()) const; 99b3ab3becSAdrian Vogelsgesang std::string string() const; 100b3ab3becSAdrian Vogelsgesang std::wstring wstring() const; 101b3ab3becSAdrian Vogelsgesang std::u8string u8string() const; 102b3ab3becSAdrian Vogelsgesang std::u16string u16string() const; 103b3ab3becSAdrian Vogelsgesang std::u32string u32string() const; 104b3ab3becSAdrian Vogelsgesang 105b3ab3becSAdrian Vogelsgesang template<class EcharT, class traits = char_traits<EcharT>, 106b3ab3becSAdrian Vogelsgesang class Allocator = allocator<EcharT>> 107b3ab3becSAdrian Vogelsgesang basic_string<EcharT, traits, Allocator> 108b3ab3becSAdrian Vogelsgesang generic_string(const Allocator& a = Allocator()) const; 109b3ab3becSAdrian Vogelsgesang std::string generic_string() const; 110b3ab3becSAdrian Vogelsgesang std::wstring generic_wstring() const; 111b3ab3becSAdrian Vogelsgesang std::u8string generic_u8string() const; 112b3ab3becSAdrian Vogelsgesang std::u16string generic_u16string() const; 113b3ab3becSAdrian Vogelsgesang std::u32string generic_u32string() const; 114b3ab3becSAdrian Vogelsgesang 115b3ab3becSAdrian Vogelsgesang int compare(const path& p) const noexcept; 116b3ab3becSAdrian Vogelsgesang int compare(const string_type& s) const; 117b3ab3becSAdrian Vogelsgesang int compare(basic_string_view<value_type> s) const; 118b3ab3becSAdrian Vogelsgesang int compare(const value_type* s) const; 119b3ab3becSAdrian Vogelsgesang 120b3ab3becSAdrian Vogelsgesang path root_name() const; 121b3ab3becSAdrian Vogelsgesang path root_directory() const; 122b3ab3becSAdrian Vogelsgesang path root_path() const; 123b3ab3becSAdrian Vogelsgesang path relative_path() const; 124b3ab3becSAdrian Vogelsgesang path parent_path() const; 125b3ab3becSAdrian Vogelsgesang path filename() const; 126b3ab3becSAdrian Vogelsgesang path stem() const; 127b3ab3becSAdrian Vogelsgesang path extension() const; 128b3ab3becSAdrian Vogelsgesang 129b3ab3becSAdrian Vogelsgesang [[nodiscard]] bool empty() const noexcept; 130b3ab3becSAdrian Vogelsgesang bool has_root_name() const; 131b3ab3becSAdrian Vogelsgesang bool has_root_directory() const; 132b3ab3becSAdrian Vogelsgesang bool has_root_path() const; 133b3ab3becSAdrian Vogelsgesang bool has_relative_path() const; 134b3ab3becSAdrian Vogelsgesang bool has_parent_path() const; 135b3ab3becSAdrian Vogelsgesang bool has_filename() const; 136b3ab3becSAdrian Vogelsgesang bool has_stem() const; 137b3ab3becSAdrian Vogelsgesang bool has_extension() const; 138b3ab3becSAdrian Vogelsgesang bool is_absolute() const; 139b3ab3becSAdrian Vogelsgesang bool is_relative() const; 140b3ab3becSAdrian Vogelsgesang 141b3ab3becSAdrian Vogelsgesang path lexically_normal() const; 142b3ab3becSAdrian Vogelsgesang path lexically_relative(const path& base) const; 143b3ab3becSAdrian Vogelsgesang path lexically_proximate(const path& base) const; 144b3ab3becSAdrian Vogelsgesang 145b3ab3becSAdrian Vogelsgesang class iterator; 146b3ab3becSAdrian Vogelsgesang using const_iterator = iterator; 147b3ab3becSAdrian Vogelsgesang 148b3ab3becSAdrian Vogelsgesang iterator begin() const; 149b3ab3becSAdrian Vogelsgesang iterator end() const; 150b3ab3becSAdrian Vogelsgesang 151998a5c88SEric Fiselier template<class charT, class traits> 152998a5c88SEric Fiselier friend basic_ostream<charT, traits>& 153998a5c88SEric Fiselier operator<<(basic_ostream<charT, traits>& os, const path& p); 154998a5c88SEric Fiselier template<class charT, class traits> 155998a5c88SEric Fiselier friend basic_istream<charT, traits>& 156998a5c88SEric Fiselier operator>>(basic_istream<charT, traits>& is, path& p); 157b3ab3becSAdrian Vogelsgesang }; 158b3ab3becSAdrian Vogelsgesang 159b3ab3becSAdrian Vogelsgesang void swap(path& lhs, path& rhs) noexcept; 160b3ab3becSAdrian Vogelsgesang size_t hash_value(const path& p) noexcept; 161998a5c88SEric Fiselier 1621cf344d9SLouis Dionne // [fs.path.hash], hash support 1631cf344d9SLouis Dionne template<> struct hash<filesystem::path>; 1641cf344d9SLouis Dionne 165998a5c88SEric Fiselier template <class Source> 166998a5c88SEric Fiselier path u8path(const Source& source); 167998a5c88SEric Fiselier template <class InputIterator> 168998a5c88SEric Fiselier path u8path(InputIterator first, InputIterator last); 169998a5c88SEric Fiselier 170998a5c88SEric Fiselier class filesystem_error; 171f1974f03SAdrian Vogelsgesang 172f1974f03SAdrian Vogelsgesang class directory_entry { 173f1974f03SAdrian Vogelsgesang public: 174f1974f03SAdrian Vogelsgesang directory_entry() noexcept = default; 175f1974f03SAdrian Vogelsgesang directory_entry(const directory_entry&) = default; 176f1974f03SAdrian Vogelsgesang directory_entry(directory_entry&&) noexcept = default; 177f1974f03SAdrian Vogelsgesang explicit directory_entry(const filesystem::path& p); 178f1974f03SAdrian Vogelsgesang directory_entry(const filesystem::path& p, error_code& ec); 179f1974f03SAdrian Vogelsgesang ~directory_entry(); 180f1974f03SAdrian Vogelsgesang 181f1974f03SAdrian Vogelsgesang directory_entry& operator=(const directory_entry&) = default; 182f1974f03SAdrian Vogelsgesang directory_entry& operator=(directory_entry&&) noexcept = default; 183f1974f03SAdrian Vogelsgesang 184f1974f03SAdrian Vogelsgesang void assign(const filesystem::path& p); 185f1974f03SAdrian Vogelsgesang void assign(const filesystem::path& p, error_code& ec); 186f1974f03SAdrian Vogelsgesang void replace_filename(const filesystem::path& p); 187f1974f03SAdrian Vogelsgesang void replace_filename(const filesystem::path& p, error_code& ec); 188f1974f03SAdrian Vogelsgesang void refresh(); 189f1974f03SAdrian Vogelsgesang void refresh(error_code& ec) noexcept; 190f1974f03SAdrian Vogelsgesang 191f1974f03SAdrian Vogelsgesang const filesystem::path& path() const noexcept; 192f1974f03SAdrian Vogelsgesang operator const filesystem::path&() const noexcept; 193f1974f03SAdrian Vogelsgesang bool exists() const; 194f1974f03SAdrian Vogelsgesang bool exists(error_code& ec) const noexcept; 195f1974f03SAdrian Vogelsgesang bool is_block_file() const; 196f1974f03SAdrian Vogelsgesang bool is_block_file(error_code& ec) const noexcept; 197f1974f03SAdrian Vogelsgesang bool is_character_file() const; 198f1974f03SAdrian Vogelsgesang bool is_character_file(error_code& ec) const noexcept; 199f1974f03SAdrian Vogelsgesang bool is_directory() const; 200f1974f03SAdrian Vogelsgesang bool is_directory(error_code& ec) const noexcept; 201f1974f03SAdrian Vogelsgesang bool is_fifo() const; 202f1974f03SAdrian Vogelsgesang bool is_fifo(error_code& ec) const noexcept; 203f1974f03SAdrian Vogelsgesang bool is_other() const; 204f1974f03SAdrian Vogelsgesang bool is_other(error_code& ec) const noexcept; 205f1974f03SAdrian Vogelsgesang bool is_regular_file() const; 206f1974f03SAdrian Vogelsgesang bool is_regular_file(error_code& ec) const noexcept; 207f1974f03SAdrian Vogelsgesang bool is_socket() const; 208f1974f03SAdrian Vogelsgesang bool is_socket(error_code& ec) const noexcept; 209f1974f03SAdrian Vogelsgesang bool is_symlink() const; 210f1974f03SAdrian Vogelsgesang bool is_symlink(error_code& ec) const noexcept; 211f1974f03SAdrian Vogelsgesang uintmax_t file_size() const; 212f1974f03SAdrian Vogelsgesang uintmax_t file_size(error_code& ec) const noexcept; 213f1974f03SAdrian Vogelsgesang uintmax_t hard_link_count() const; 214f1974f03SAdrian Vogelsgesang uintmax_t hard_link_count(error_code& ec) const noexcept; 215f1974f03SAdrian Vogelsgesang file_time_type last_write_time() const; 216f1974f03SAdrian Vogelsgesang file_time_type last_write_time(error_code& ec) const noexcept; 217f1974f03SAdrian Vogelsgesang file_status status() const; 218f1974f03SAdrian Vogelsgesang file_status status(error_code& ec) const noexcept; 219f1974f03SAdrian Vogelsgesang file_status symlink_status() const; 220f1974f03SAdrian Vogelsgesang file_status symlink_status(error_code& ec) const noexcept; 221f1974f03SAdrian Vogelsgesang 222f1974f03SAdrian Vogelsgesang bool operator==(const directory_entry& rhs) const noexcept; 223f1974f03SAdrian Vogelsgesang bool operator!=(const directory_entry& rhs) const noexcept; // removed in C++20 224f1974f03SAdrian Vogelsgesang bool operator< (const directory_entry& rhs) const noexcept; // removed in C++20 225f1974f03SAdrian Vogelsgesang bool operator<=(const directory_entry& rhs) const noexcept; // removed in C++20 226f1974f03SAdrian Vogelsgesang bool operator> (const directory_entry& rhs) const noexcept; // removed in C++20 227f1974f03SAdrian Vogelsgesang bool operator>=(const directory_entry& rhs) const noexcept; // removed in C++20 228f1974f03SAdrian Vogelsgesang strong_ordering operator<=>(const directory_entry& rhs) const noexcept; // since C++20 229f1974f03SAdrian Vogelsgesang 230f1974f03SAdrian Vogelsgesang template<class charT, class traits> 231f1974f03SAdrian Vogelsgesang friend basic_ostream<charT, traits>& 232f1974f03SAdrian Vogelsgesang operator<<(basic_ostream<charT, traits>& os, const directory_entry& d); 233f1974f03SAdrian Vogelsgesang 234f1974f03SAdrian Vogelsgesang private: 235f1974f03SAdrian Vogelsgesang filesystem::path pathobject; // exposition only 236f1974f03SAdrian Vogelsgesang friend class directory_iterator; // exposition only 237f1974f03SAdrian Vogelsgesang }; 238998a5c88SEric Fiselier 2395f8e4315SHristo Hristov class directory_iterator { 2405f8e4315SHristo Hristov public: 2415f8e4315SHristo Hristov using iterator_category = input_iterator_tag; 2425f8e4315SHristo Hristov using value_type = directory_entry; 2435f8e4315SHristo Hristov using difference_type = ptrdiff_t; 2445f8e4315SHristo Hristov using pointer = const directory_entry*; 2455f8e4315SHristo Hristov using reference = const directory_entry&; 2465f8e4315SHristo Hristov 2475f8e4315SHristo Hristov // [fs.dir.itr.members], member functions 2485f8e4315SHristo Hristov directory_iterator() noexcept; 2495f8e4315SHristo Hristov explicit directory_iterator(const path& p); 2505f8e4315SHristo Hristov directory_iterator(const path& p, directory_options options); 2515f8e4315SHristo Hristov directory_iterator(const path& p, error_code& ec); 2525f8e4315SHristo Hristov directory_iterator(const path& p, directory_options options, 2535f8e4315SHristo Hristov error_code& ec); 2545f8e4315SHristo Hristov directory_iterator(const directory_iterator& rhs); 2555f8e4315SHristo Hristov directory_iterator(directory_iterator&& rhs) noexcept; 2565f8e4315SHristo Hristov ~directory_iterator(); 2575f8e4315SHristo Hristov 2585f8e4315SHristo Hristov directory_iterator& operator=(const directory_iterator& rhs); 2595f8e4315SHristo Hristov directory_iterator& operator=(directory_iterator&& rhs) noexcept; 2605f8e4315SHristo Hristov 2615f8e4315SHristo Hristov const directory_entry& operator*() const; 2625f8e4315SHristo Hristov const directory_entry* operator->() const; 2635f8e4315SHristo Hristov directory_iterator& operator++(); 2645f8e4315SHristo Hristov directory_iterator& increment(error_code& ec); 2655f8e4315SHristo Hristov 2665f8e4315SHristo Hristov bool operator==(default_sentinel_t) const noexcept { // since C++20 2675f8e4315SHristo Hristov return *this == directory_iterator(); 2685f8e4315SHristo Hristov } 2695f8e4315SHristo Hristov 2705f8e4315SHristo Hristov // other members as required by [input.iterators], input iterators 2715f8e4315SHristo Hristov }; 272998a5c88SEric Fiselier 273998a5c88SEric Fiselier // enable directory_iterator range-based for statements 274998a5c88SEric Fiselier directory_iterator begin(directory_iterator iter) noexcept; 2751fa27f2aSJoe Loser directory_iterator end(directory_iterator) noexcept; 276998a5c88SEric Fiselier 2775f8e4315SHristo Hristovclass recursive_directory_iterator { 2785f8e4315SHristo Hristov public: 2795f8e4315SHristo Hristov using iterator_category = input_iterator_tag; 2805f8e4315SHristo Hristov using value_type = directory_entry; 2815f8e4315SHristo Hristov using difference_type = ptrdiff_t; 2825f8e4315SHristo Hristov using pointer = const directory_entry*; 2835f8e4315SHristo Hristov using reference = const directory_entry&; 2845f8e4315SHristo Hristov 2855f8e4315SHristo Hristov // [fs.rec.dir.itr.members], constructors and destructor 2865f8e4315SHristo Hristov recursive_directory_iterator() noexcept; 2875f8e4315SHristo Hristov explicit recursive_directory_iterator(const path& p); 2885f8e4315SHristo Hristov recursive_directory_iterator(const path& p, directory_options options); 2895f8e4315SHristo Hristov recursive_directory_iterator(const path& p, directory_options options, 2905f8e4315SHristo Hristov error_code& ec); 2915f8e4315SHristo Hristov recursive_directory_iterator(const path& p, error_code& ec); 2925f8e4315SHristo Hristov recursive_directory_iterator(const recursive_directory_iterator& rhs); 2935f8e4315SHristo Hristov recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; 2945f8e4315SHristo Hristov ~recursive_directory_iterator(); 2955f8e4315SHristo Hristov 2965f8e4315SHristo Hristov // [fs.rec.dir.itr.members], observers 2975f8e4315SHristo Hristov directory_options options() const; 2985f8e4315SHristo Hristov int depth() const; 2995f8e4315SHristo Hristov bool recursion_pending() const; 3005f8e4315SHristo Hristov 3015f8e4315SHristo Hristov const directory_entry& operator*() const; 3025f8e4315SHristo Hristov const directory_entry* operator->() const; 3035f8e4315SHristo Hristov 3045f8e4315SHristo Hristov // [fs.rec.dir.itr.members], modifiers 3055f8e4315SHristo Hristov recursive_directory_iterator& 3065f8e4315SHristo Hristov operator=(const recursive_directory_iterator& rhs); 3075f8e4315SHristo Hristov recursive_directory_iterator& 3085f8e4315SHristo Hristov operator=(recursive_directory_iterator&& rhs) noexcept; 3095f8e4315SHristo Hristov 3105f8e4315SHristo Hristov recursive_directory_iterator& operator++(); 3115f8e4315SHristo Hristov recursive_directory_iterator& increment(error_code& ec); 3125f8e4315SHristo Hristov 3135f8e4315SHristo Hristov void pop(); 3145f8e4315SHristo Hristov void pop(error_code& ec); 3155f8e4315SHristo Hristov void disable_recursion_pending(); 3165f8e4315SHristo Hristov 3175f8e4315SHristo Hristov bool operator==(default_sentinel_t) const noexcept { // since C++20 3185f8e4315SHristo Hristov return *this == recursive_directory_iterator(); 3195f8e4315SHristo Hristov } 3205f8e4315SHristo Hristov 3215f8e4315SHristo Hristov // other members as required by [input.iterators], input iterators 3225f8e4315SHristo Hristov }; 323998a5c88SEric Fiselier 324998a5c88SEric Fiselier // enable recursive_directory_iterator range-based for statements 325998a5c88SEric Fiselier recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; 3261fa27f2aSJoe Loser recursive_directory_iterator end(recursive_directory_iterator) noexcept; 327998a5c88SEric Fiselier 328a9e0321fSHristo Hristov class file_status { 329a9e0321fSHristo Hristov public: 330a9e0321fSHristo Hristov // [fs.file.status.cons], constructors and destructor 331a9e0321fSHristo Hristov file_status() noexcept : file_status(file_type::none) {} 332a9e0321fSHristo Hristov explicit file_status(file_type ft, 333a9e0321fSHristo Hristov perms prms = perms::unknown) noexcept; 334a9e0321fSHristo Hristov file_status(const file_status&) noexcept = default; 335a9e0321fSHristo Hristov file_status(file_status&&) noexcept = default; 336a9e0321fSHristo Hristov ~file_status(); 337a9e0321fSHristo Hristov 338a9e0321fSHristo Hristov // assignments 339a9e0321fSHristo Hristov file_status& operator=(const file_status&) noexcept = default; 340a9e0321fSHristo Hristov file_status& operator=(file_status&&) noexcept = default; 341a9e0321fSHristo Hristov 342a9e0321fSHristo Hristov // [fs.file.status.mods], modifiers 343a9e0321fSHristo Hristov void type(file_type ft) noexcept; 344a9e0321fSHristo Hristov void permissions(perms prms) noexcept; 345a9e0321fSHristo Hristov 346a9e0321fSHristo Hristov // [fs.file.status.obs], observers 347a9e0321fSHristo Hristov file_type type() const noexcept; 348a9e0321fSHristo Hristov perms permissions() const noexcept; 349a9e0321fSHristo Hristov 350a9e0321fSHristo Hristov friend bool operator==(const file_status& lhs, const file_status& rhs) noexcept 351a9e0321fSHristo Hristov { return lhs.type() == rhs.type() && lhs.permissions() == rhs.permissions(); } // C++20 352a9e0321fSHristo Hristov }; 353998a5c88SEric Fiselier 354998a5c88SEric Fiselier struct space_info 355998a5c88SEric Fiselier { 356998a5c88SEric Fiselier uintmax_t capacity; 357998a5c88SEric Fiselier uintmax_t free; 358998a5c88SEric Fiselier uintmax_t available; 359706b3951SAdrian Vogelsgesang 360706b3951SAdrian Vogelsgesang friend bool operator==(const space_info&, const space_info&) = default; // C++20 361998a5c88SEric Fiselier }; 362998a5c88SEric Fiselier 363998a5c88SEric Fiselier enum class file_type; 364998a5c88SEric Fiselier enum class perms; 365998a5c88SEric Fiselier enum class perm_options; 366998a5c88SEric Fiselier enum class copy_options; 367998a5c88SEric Fiselier enum class directory_options; 368998a5c88SEric Fiselier 369998a5c88SEric Fiselier typedef chrono::time_point<trivial-clock> file_time_type; 370998a5c88SEric Fiselier 371998a5c88SEric Fiselier // operational functions 372998a5c88SEric Fiselier 373998a5c88SEric Fiselier path absolute(const path& p); 374998a5c88SEric Fiselier path absolute(const path& p, error_code &ec); 375998a5c88SEric Fiselier 376998a5c88SEric Fiselier path canonical(const path& p); 377998a5c88SEric Fiselier path canonical(const path& p, error_code& ec); 378998a5c88SEric Fiselier 379998a5c88SEric Fiselier void copy(const path& from, const path& to); 380998a5c88SEric Fiselier void copy(const path& from, const path& to, error_code& ec); 381998a5c88SEric Fiselier void copy(const path& from, const path& to, copy_options options); 382998a5c88SEric Fiselier void copy(const path& from, const path& to, copy_options options, 383998a5c88SEric Fiselier error_code& ec); 384998a5c88SEric Fiselier 385998a5c88SEric Fiselier bool copy_file(const path& from, const path& to); 386998a5c88SEric Fiselier bool copy_file(const path& from, const path& to, error_code& ec); 387998a5c88SEric Fiselier bool copy_file(const path& from, const path& to, copy_options option); 388998a5c88SEric Fiselier bool copy_file(const path& from, const path& to, copy_options option, 389998a5c88SEric Fiselier error_code& ec); 390998a5c88SEric Fiselier 391998a5c88SEric Fiselier void copy_symlink(const path& existing_symlink, const path& new_symlink); 392998a5c88SEric Fiselier void copy_symlink(const path& existing_symlink, const path& new_symlink, 393998a5c88SEric Fiselier error_code& ec) noexcept; 394998a5c88SEric Fiselier 395998a5c88SEric Fiselier bool create_directories(const path& p); 396998a5c88SEric Fiselier bool create_directories(const path& p, error_code& ec); 397998a5c88SEric Fiselier 398998a5c88SEric Fiselier bool create_directory(const path& p); 399998a5c88SEric Fiselier bool create_directory(const path& p, error_code& ec) noexcept; 400998a5c88SEric Fiselier 401998a5c88SEric Fiselier bool create_directory(const path& p, const path& attributes); 402998a5c88SEric Fiselier bool create_directory(const path& p, const path& attributes, 403998a5c88SEric Fiselier error_code& ec) noexcept; 404998a5c88SEric Fiselier 405998a5c88SEric Fiselier void create_directory_symlink(const path& to, const path& new_symlink); 406998a5c88SEric Fiselier void create_directory_symlink(const path& to, const path& new_symlink, 407998a5c88SEric Fiselier error_code& ec) noexcept; 408998a5c88SEric Fiselier 409998a5c88SEric Fiselier void create_hard_link(const path& to, const path& new_hard_link); 410998a5c88SEric Fiselier void create_hard_link(const path& to, const path& new_hard_link, 411998a5c88SEric Fiselier error_code& ec) noexcept; 412998a5c88SEric Fiselier 413998a5c88SEric Fiselier void create_symlink(const path& to, const path& new_symlink); 414998a5c88SEric Fiselier void create_symlink(const path& to, const path& new_symlink, 415998a5c88SEric Fiselier error_code& ec) noexcept; 416998a5c88SEric Fiselier 417998a5c88SEric Fiselier path current_path(); 418998a5c88SEric Fiselier path current_path(error_code& ec); 419998a5c88SEric Fiselier void current_path(const path& p); 420998a5c88SEric Fiselier void current_path(const path& p, error_code& ec) noexcept; 421998a5c88SEric Fiselier 422998a5c88SEric Fiselier bool exists(file_status s) noexcept; 423998a5c88SEric Fiselier bool exists(const path& p); 424998a5c88SEric Fiselier bool exists(const path& p, error_code& ec) noexcept; 425998a5c88SEric Fiselier 426998a5c88SEric Fiselier bool equivalent(const path& p1, const path& p2); 427998a5c88SEric Fiselier bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; 428998a5c88SEric Fiselier 429998a5c88SEric Fiselier uintmax_t file_size(const path& p); 430998a5c88SEric Fiselier uintmax_t file_size(const path& p, error_code& ec) noexcept; 431998a5c88SEric Fiselier 432998a5c88SEric Fiselier uintmax_t hard_link_count(const path& p); 433998a5c88SEric Fiselier uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; 434998a5c88SEric Fiselier 435998a5c88SEric Fiselier bool is_block_file(file_status s) noexcept; 436998a5c88SEric Fiselier bool is_block_file(const path& p); 437998a5c88SEric Fiselier bool is_block_file(const path& p, error_code& ec) noexcept; 438998a5c88SEric Fiselier 439998a5c88SEric Fiselier bool is_character_file(file_status s) noexcept; 440998a5c88SEric Fiselier bool is_character_file(const path& p); 441998a5c88SEric Fiselier bool is_character_file(const path& p, error_code& ec) noexcept; 442998a5c88SEric Fiselier 443998a5c88SEric Fiselier bool is_directory(file_status s) noexcept; 444998a5c88SEric Fiselier bool is_directory(const path& p); 445998a5c88SEric Fiselier bool is_directory(const path& p, error_code& ec) noexcept; 446998a5c88SEric Fiselier 447998a5c88SEric Fiselier bool is_empty(const path& p); 448998a5c88SEric Fiselier bool is_empty(const path& p, error_code& ec) noexcept; 449998a5c88SEric Fiselier 450998a5c88SEric Fiselier bool is_fifo(file_status s) noexcept; 451998a5c88SEric Fiselier bool is_fifo(const path& p); 452998a5c88SEric Fiselier bool is_fifo(const path& p, error_code& ec) noexcept; 453998a5c88SEric Fiselier 454998a5c88SEric Fiselier bool is_other(file_status s) noexcept; 455998a5c88SEric Fiselier bool is_other(const path& p); 456998a5c88SEric Fiselier bool is_other(const path& p, error_code& ec) noexcept; 457998a5c88SEric Fiselier 458998a5c88SEric Fiselier bool is_regular_file(file_status s) noexcept; 459998a5c88SEric Fiselier bool is_regular_file(const path& p); 460998a5c88SEric Fiselier bool is_regular_file(const path& p, error_code& ec) noexcept; 461998a5c88SEric Fiselier 462998a5c88SEric Fiselier bool is_socket(file_status s) noexcept; 463998a5c88SEric Fiselier bool is_socket(const path& p); 464998a5c88SEric Fiselier bool is_socket(const path& p, error_code& ec) noexcept; 465998a5c88SEric Fiselier 466998a5c88SEric Fiselier bool is_symlink(file_status s) noexcept; 467998a5c88SEric Fiselier bool is_symlink(const path& p); 468998a5c88SEric Fiselier bool is_symlink(const path& p, error_code& ec) noexcept; 469998a5c88SEric Fiselier 470998a5c88SEric Fiselier file_time_type last_write_time(const path& p); 471998a5c88SEric Fiselier file_time_type last_write_time(const path& p, error_code& ec) noexcept; 472998a5c88SEric Fiselier void last_write_time(const path& p, file_time_type new_time); 473998a5c88SEric Fiselier void last_write_time(const path& p, file_time_type new_time, 474998a5c88SEric Fiselier error_code& ec) noexcept; 475998a5c88SEric Fiselier 476998a5c88SEric Fiselier void permissions(const path& p, perms prms, 477998a5c88SEric Fiselier perm_options opts=perm_options::replace); 478998a5c88SEric Fiselier void permissions(const path& p, perms prms, error_code& ec) noexcept; 479998a5c88SEric Fiselier void permissions(const path& p, perms prms, perm_options opts, 480998a5c88SEric Fiselier error_code& ec); 481998a5c88SEric Fiselier 482998a5c88SEric Fiselier path proximate(const path& p, error_code& ec); 483998a5c88SEric Fiselier path proximate(const path& p, const path& base = current_path()); 484998a5c88SEric Fiselier path proximate(const path& p, const path& base, error_code &ec); 485998a5c88SEric Fiselier 486998a5c88SEric Fiselier path read_symlink(const path& p); 487998a5c88SEric Fiselier path read_symlink(const path& p, error_code& ec); 488998a5c88SEric Fiselier 489998a5c88SEric Fiselier path relative(const path& p, error_code& ec); 490998a5c88SEric Fiselier path relative(const path& p, const path& base=current_path()); 491998a5c88SEric Fiselier path relative(const path& p, const path& base, error_code& ec); 492998a5c88SEric Fiselier 493998a5c88SEric Fiselier bool remove(const path& p); 494998a5c88SEric Fiselier bool remove(const path& p, error_code& ec) noexcept; 495998a5c88SEric Fiselier 496998a5c88SEric Fiselier uintmax_t remove_all(const path& p); 497998a5c88SEric Fiselier uintmax_t remove_all(const path& p, error_code& ec); 498998a5c88SEric Fiselier 499998a5c88SEric Fiselier void rename(const path& from, const path& to); 500998a5c88SEric Fiselier void rename(const path& from, const path& to, error_code& ec) noexcept; 501998a5c88SEric Fiselier 502998a5c88SEric Fiselier void resize_file(const path& p, uintmax_t size); 503998a5c88SEric Fiselier void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; 504998a5c88SEric Fiselier 505998a5c88SEric Fiselier space_info space(const path& p); 506998a5c88SEric Fiselier space_info space(const path& p, error_code& ec) noexcept; 507998a5c88SEric Fiselier 508998a5c88SEric Fiselier file_status status(const path& p); 509998a5c88SEric Fiselier file_status status(const path& p, error_code& ec) noexcept; 510998a5c88SEric Fiselier 511998a5c88SEric Fiselier bool status_known(file_status s) noexcept; 512998a5c88SEric Fiselier 513998a5c88SEric Fiselier file_status symlink_status(const path& p); 514998a5c88SEric Fiselier file_status symlink_status(const path& p, error_code& ec) noexcept; 515998a5c88SEric Fiselier 516998a5c88SEric Fiselier path temp_directory_path(); 517998a5c88SEric Fiselier path temp_directory_path(error_code& ec); 518998a5c88SEric Fiselier 519998a5c88SEric Fiselier path weakly_canonical(path const& p); 520998a5c88SEric Fiselier path weakly_canonical(path const& p, error_code& ec); 521998a5c88SEric Fiselier 5221fa27f2aSJoe Loser} // namespace std::filesystem 523998a5c88SEric Fiselier 5241fa27f2aSJoe Losertemplate <> 5251fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; 5261fa27f2aSJoe Losertemplate <> 5271fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; 5281fa27f2aSJoe Loser 5291fa27f2aSJoe Losertemplate <> 5301fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; 5311fa27f2aSJoe Losertemplate <> 5321fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; 533998a5c88SEric Fiselier 534998a5c88SEric Fiselier*/ 535998a5c88SEric Fiselier 536*b9a2658aSNikolas Klauser#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 537*b9a2658aSNikolas Klauser# include <__cxx03/filesystem> 538*b9a2658aSNikolas Klauser#else 53923f1cd9eSNikolas Klauser# include <__config> 540dfddc0c4SNikolas Klauser 541dfddc0c4SNikolas Klauser# if _LIBCPP_STD_VER >= 17 5427056250fSNikolas Klauser# include <__filesystem/copy_options.h> 5437056250fSNikolas Klauser# include <__filesystem/directory_entry.h> 5447056250fSNikolas Klauser# include <__filesystem/directory_iterator.h> 5457056250fSNikolas Klauser# include <__filesystem/directory_options.h> 5467056250fSNikolas Klauser# include <__filesystem/file_status.h> 5477056250fSNikolas Klauser# include <__filesystem/file_time_type.h> 5487056250fSNikolas Klauser# include <__filesystem/file_type.h> 5497056250fSNikolas Klauser# include <__filesystem/filesystem_error.h> 5507056250fSNikolas Klauser# include <__filesystem/operations.h> 5517056250fSNikolas Klauser# include <__filesystem/path.h> 5524d81a46fSArthur O'Dwyer# include <__filesystem/path_iterator.h> 5537056250fSNikolas Klauser# include <__filesystem/perm_options.h> 5547056250fSNikolas Klauser# include <__filesystem/perms.h> 5557056250fSNikolas Klauser# include <__filesystem/recursive_directory_iterator.h> 5567056250fSNikolas Klauser# include <__filesystem/space_info.h> 5577056250fSNikolas Klauser# include <__filesystem/u8path.h> 558dfddc0c4SNikolas Klauser# endif 559dfddc0c4SNikolas Klauser 560f56972e2SMarshall Clow# include <version> 561998a5c88SEric Fiselier 562db1978b6SNikolas Klauser// standard-mandated includes 563473a1605SNikolas Klauser 564473a1605SNikolas Klauser// [fs.filesystem.syn] 565db1978b6SNikolas Klauser# include <compare> 566db1978b6SNikolas Klauser 567998a5c88SEric Fiselier# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 568998a5c88SEric Fiselier# pragma GCC system_header 569998a5c88SEric Fiselier# endif 570998a5c88SEric Fiselier 57189b356f0SNikolas Klauser# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 57289b356f0SNikolas Klauser# include <concepts> 57375196f8eSNikolas Klauser# include <cstdlib> 57433de5a31SNikolas Klauser# include <cstring> 575a65070a7Sphilnik777# include <iosfwd> 576a65070a7Sphilnik777# include <new> 577e8cfbfd0SMark de Wever# include <system_error> 57889b356f0SNikolas Klauser# endif 579*b9a2658aSNikolas Klauser#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 58089b356f0SNikolas Klauser 581998a5c88SEric Fiselier#endif // _LIBCPP_FILESYSTEM 582