xref: /freebsd/contrib/llvm-project/libcxx/include/filesystem (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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//===----------------------------------------------------------------------===//
9*bdd1243dSDimitry 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
18*bdd1243dSDimitry Andric    // `class path` from http://eel.is/c++draft/fs.class.path.general#6
19*bdd1243dSDimitry Andric    class path {
20*bdd1243dSDimitry Andric      public:
21*bdd1243dSDimitry Andric        using value_type  = see below;
22*bdd1243dSDimitry Andric        using string_type = basic_string<value_type>;
23*bdd1243dSDimitry Andric        static constexpr value_type preferred_separator = see below;
240b57cec5SDimitry Andric
25*bdd1243dSDimitry Andric        enum format;
260b57cec5SDimitry Andric
27*bdd1243dSDimitry Andric        path() noexcept;
28*bdd1243dSDimitry Andric        path(const path& p);
29*bdd1243dSDimitry Andric        path(path&& p) noexcept;
30*bdd1243dSDimitry Andric        path(string_type&& source, format fmt = auto_format);
31*bdd1243dSDimitry Andric        template<class Source>
32*bdd1243dSDimitry Andric          path(const Source& source, format fmt = auto_format);
33*bdd1243dSDimitry Andric        template<class InputIterator>
34*bdd1243dSDimitry Andric          path(InputIterator first, InputIterator last, format fmt = auto_format);
35*bdd1243dSDimitry Andric        template<class Source>
36*bdd1243dSDimitry Andric          path(const Source& source, const locale& loc, format fmt = auto_format);
37*bdd1243dSDimitry Andric        template<class InputIterator>
38*bdd1243dSDimitry Andric          path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
39*bdd1243dSDimitry Andric        ~path();
400b57cec5SDimitry Andric
41*bdd1243dSDimitry Andric        path& operator=(const path& p);
42*bdd1243dSDimitry Andric        path& operator=(path&& p) noexcept;
43*bdd1243dSDimitry Andric        path& operator=(string_type&& source);
44*bdd1243dSDimitry Andric        path& assign(string_type&& source);
45*bdd1243dSDimitry Andric        template<class Source>
46*bdd1243dSDimitry Andric          path& operator=(const Source& source);
47*bdd1243dSDimitry Andric        template<class Source>
48*bdd1243dSDimitry Andric          path& assign(const Source& source);
49*bdd1243dSDimitry Andric        template<class InputIterator>
50*bdd1243dSDimitry Andric          path& assign(InputIterator first, InputIterator last);
510b57cec5SDimitry Andric
52*bdd1243dSDimitry Andric        path& operator/=(const path& p);
53*bdd1243dSDimitry Andric        template<class Source>
54*bdd1243dSDimitry Andric          path& operator/=(const Source& source);
55*bdd1243dSDimitry Andric        template<class Source>
56*bdd1243dSDimitry Andric          path& append(const Source& source);
57*bdd1243dSDimitry Andric        template<class InputIterator>
58*bdd1243dSDimitry Andric          path& append(InputIterator first, InputIterator last);
59*bdd1243dSDimitry Andric
60*bdd1243dSDimitry Andric        path& operator+=(const path& x);
61*bdd1243dSDimitry Andric        path& operator+=(const string_type& x);
62*bdd1243dSDimitry Andric        path& operator+=(basic_string_view<value_type> x);
63*bdd1243dSDimitry Andric        path& operator+=(const value_type* x);
64*bdd1243dSDimitry Andric        path& operator+=(value_type x);
65*bdd1243dSDimitry Andric        template<class Source>
66*bdd1243dSDimitry Andric          path& operator+=(const Source& x);
67*bdd1243dSDimitry Andric        template<class EcharT>
68*bdd1243dSDimitry Andric          path& operator+=(EcharT x);
69*bdd1243dSDimitry Andric        template<class Source>
70*bdd1243dSDimitry Andric          path& concat(const Source& x);
71*bdd1243dSDimitry Andric        template<class InputIterator>
72*bdd1243dSDimitry Andric          path& concat(InputIterator first, InputIterator last);
73*bdd1243dSDimitry Andric
74*bdd1243dSDimitry Andric        void  clear() noexcept;
75*bdd1243dSDimitry Andric        path& make_preferred();
76*bdd1243dSDimitry Andric        path& remove_filename();
77*bdd1243dSDimitry Andric        path& replace_filename(const path& replacement);
78*bdd1243dSDimitry Andric        path& replace_extension(const path& replacement = path());
79*bdd1243dSDimitry Andric        void  swap(path& rhs) noexcept;
80*bdd1243dSDimitry Andric
81*bdd1243dSDimitry Andric        friend bool operator==(const path& lhs, const path& rhs) noexcept;
82*bdd1243dSDimitry Andric        friend bool operator!=(const path& lhs, const path& rhs) noexcept;             // removed in C++20
83*bdd1243dSDimitry Andric        friend bool operator< (const path& lhs, const path& rhs) noexcept;             // removed in C++20
84*bdd1243dSDimitry Andric        friend bool operator<=(const path& lhs, const path& rhs) noexcept;             // removed in C++20
85*bdd1243dSDimitry Andric        friend bool operator> (const path& lhs, const path& rhs) noexcept;             // removed in C++20
86*bdd1243dSDimitry Andric        friend bool operator>=(const path& lhs, const path& rhs) noexcept;             // removed in C++20
87*bdd1243dSDimitry Andric        friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept; // C++20
88*bdd1243dSDimitry Andric
89*bdd1243dSDimitry Andric        friend path operator/(const path& lhs, const path& rhs);
90*bdd1243dSDimitry Andric
91*bdd1243dSDimitry Andric        const string_type& native() const noexcept;
92*bdd1243dSDimitry Andric        const value_type*  c_str() const noexcept;
93*bdd1243dSDimitry Andric        operator string_type() const;
94*bdd1243dSDimitry Andric
95*bdd1243dSDimitry Andric        template<class EcharT, class traits = char_traits<EcharT>,
96*bdd1243dSDimitry Andric                 class Allocator = allocator<EcharT>>
97*bdd1243dSDimitry Andric          basic_string<EcharT, traits, Allocator>
98*bdd1243dSDimitry Andric            string(const Allocator& a = Allocator()) const;
99*bdd1243dSDimitry Andric        std::string    string() const;
100*bdd1243dSDimitry Andric        std::wstring   wstring() const;
101*bdd1243dSDimitry Andric        std::u8string  u8string() const;
102*bdd1243dSDimitry Andric        std::u16string u16string() const;
103*bdd1243dSDimitry Andric        std::u32string u32string() const;
104*bdd1243dSDimitry Andric
105*bdd1243dSDimitry Andric        template<class EcharT, class traits = char_traits<EcharT>,
106*bdd1243dSDimitry Andric                 class Allocator = allocator<EcharT>>
107*bdd1243dSDimitry Andric          basic_string<EcharT, traits, Allocator>
108*bdd1243dSDimitry Andric            generic_string(const Allocator& a = Allocator()) const;
109*bdd1243dSDimitry Andric        std::string    generic_string() const;
110*bdd1243dSDimitry Andric        std::wstring   generic_wstring() const;
111*bdd1243dSDimitry Andric        std::u8string  generic_u8string() const;
112*bdd1243dSDimitry Andric        std::u16string generic_u16string() const;
113*bdd1243dSDimitry Andric        std::u32string generic_u32string() const;
114*bdd1243dSDimitry Andric
115*bdd1243dSDimitry Andric        int compare(const path& p) const noexcept;
116*bdd1243dSDimitry Andric        int compare(const string_type& s) const;
117*bdd1243dSDimitry Andric        int compare(basic_string_view<value_type> s) const;
118*bdd1243dSDimitry Andric        int compare(const value_type* s) const;
119*bdd1243dSDimitry Andric
120*bdd1243dSDimitry Andric        path root_name() const;
121*bdd1243dSDimitry Andric        path root_directory() const;
122*bdd1243dSDimitry Andric        path root_path() const;
123*bdd1243dSDimitry Andric        path relative_path() const;
124*bdd1243dSDimitry Andric        path parent_path() const;
125*bdd1243dSDimitry Andric        path filename() const;
126*bdd1243dSDimitry Andric        path stem() const;
127*bdd1243dSDimitry Andric        path extension() const;
128*bdd1243dSDimitry Andric
129*bdd1243dSDimitry Andric        [[nodiscard]] bool empty() const noexcept;
130*bdd1243dSDimitry Andric        bool has_root_name() const;
131*bdd1243dSDimitry Andric        bool has_root_directory() const;
132*bdd1243dSDimitry Andric        bool has_root_path() const;
133*bdd1243dSDimitry Andric        bool has_relative_path() const;
134*bdd1243dSDimitry Andric        bool has_parent_path() const;
135*bdd1243dSDimitry Andric        bool has_filename() const;
136*bdd1243dSDimitry Andric        bool has_stem() const;
137*bdd1243dSDimitry Andric        bool has_extension() const;
138*bdd1243dSDimitry Andric        bool is_absolute() const;
139*bdd1243dSDimitry Andric        bool is_relative() const;
140*bdd1243dSDimitry Andric
141*bdd1243dSDimitry Andric        path lexically_normal() const;
142*bdd1243dSDimitry Andric        path lexically_relative(const path& base) const;
143*bdd1243dSDimitry Andric        path lexically_proximate(const path& base) const;
144*bdd1243dSDimitry Andric
145*bdd1243dSDimitry Andric        class iterator;
146*bdd1243dSDimitry Andric        using const_iterator = iterator;
147*bdd1243dSDimitry Andric
148*bdd1243dSDimitry Andric        iterator begin() const;
149*bdd1243dSDimitry Andric        iterator end() const;
150*bdd1243dSDimitry 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);
157*bdd1243dSDimitry Andric    };
158*bdd1243dSDimitry Andric
159*bdd1243dSDimitry Andric    void swap(path& lhs, path& rhs) noexcept;
160*bdd1243dSDimitry Andric    size_t hash_value(const path& p) noexcept;
1610b57cec5SDimitry Andric
1620b57cec5SDimitry Andric    template <class Source>
1630b57cec5SDimitry Andric      path u8path(const Source& source);
1640b57cec5SDimitry Andric    template <class InputIterator>
1650b57cec5SDimitry Andric      path u8path(InputIterator first, InputIterator last);
1660b57cec5SDimitry Andric
1670b57cec5SDimitry Andric    class filesystem_error;
168*bdd1243dSDimitry Andric
169*bdd1243dSDimitry Andric    class directory_entry {
170*bdd1243dSDimitry Andric    public:
171*bdd1243dSDimitry Andric      directory_entry() noexcept = default;
172*bdd1243dSDimitry Andric      directory_entry(const directory_entry&) = default;
173*bdd1243dSDimitry Andric      directory_entry(directory_entry&&) noexcept = default;
174*bdd1243dSDimitry Andric      explicit directory_entry(const filesystem::path& p);
175*bdd1243dSDimitry Andric      directory_entry(const filesystem::path& p, error_code& ec);
176*bdd1243dSDimitry Andric      ~directory_entry();
177*bdd1243dSDimitry Andric
178*bdd1243dSDimitry Andric      directory_entry& operator=(const directory_entry&) = default;
179*bdd1243dSDimitry Andric      directory_entry& operator=(directory_entry&&) noexcept = default;
180*bdd1243dSDimitry Andric
181*bdd1243dSDimitry Andric      void assign(const filesystem::path& p);
182*bdd1243dSDimitry Andric      void assign(const filesystem::path& p, error_code& ec);
183*bdd1243dSDimitry Andric      void replace_filename(const filesystem::path& p);
184*bdd1243dSDimitry Andric      void replace_filename(const filesystem::path& p, error_code& ec);
185*bdd1243dSDimitry Andric      void refresh();
186*bdd1243dSDimitry Andric      void refresh(error_code& ec) noexcept;
187*bdd1243dSDimitry Andric
188*bdd1243dSDimitry Andric      const filesystem::path& path() const noexcept;
189*bdd1243dSDimitry Andric      operator const filesystem::path&() const noexcept;
190*bdd1243dSDimitry Andric      bool exists() const;
191*bdd1243dSDimitry Andric      bool exists(error_code& ec) const noexcept;
192*bdd1243dSDimitry Andric      bool is_block_file() const;
193*bdd1243dSDimitry Andric      bool is_block_file(error_code& ec) const noexcept;
194*bdd1243dSDimitry Andric      bool is_character_file() const;
195*bdd1243dSDimitry Andric      bool is_character_file(error_code& ec) const noexcept;
196*bdd1243dSDimitry Andric      bool is_directory() const;
197*bdd1243dSDimitry Andric      bool is_directory(error_code& ec) const noexcept;
198*bdd1243dSDimitry Andric      bool is_fifo() const;
199*bdd1243dSDimitry Andric      bool is_fifo(error_code& ec) const noexcept;
200*bdd1243dSDimitry Andric      bool is_other() const;
201*bdd1243dSDimitry Andric      bool is_other(error_code& ec) const noexcept;
202*bdd1243dSDimitry Andric      bool is_regular_file() const;
203*bdd1243dSDimitry Andric      bool is_regular_file(error_code& ec) const noexcept;
204*bdd1243dSDimitry Andric      bool is_socket() const;
205*bdd1243dSDimitry Andric      bool is_socket(error_code& ec) const noexcept;
206*bdd1243dSDimitry Andric      bool is_symlink() const;
207*bdd1243dSDimitry Andric      bool is_symlink(error_code& ec) const noexcept;
208*bdd1243dSDimitry Andric      uintmax_t file_size() const;
209*bdd1243dSDimitry Andric      uintmax_t file_size(error_code& ec) const noexcept;
210*bdd1243dSDimitry Andric      uintmax_t hard_link_count() const;
211*bdd1243dSDimitry Andric      uintmax_t hard_link_count(error_code& ec) const noexcept;
212*bdd1243dSDimitry Andric      file_time_type last_write_time() const;
213*bdd1243dSDimitry Andric      file_time_type last_write_time(error_code& ec) const noexcept;
214*bdd1243dSDimitry Andric      file_status status() const;
215*bdd1243dSDimitry Andric      file_status status(error_code& ec) const noexcept;
216*bdd1243dSDimitry Andric      file_status symlink_status() const;
217*bdd1243dSDimitry Andric      file_status symlink_status(error_code& ec) const noexcept;
218*bdd1243dSDimitry Andric
219*bdd1243dSDimitry Andric      bool operator==(const directory_entry& rhs) const noexcept;
220*bdd1243dSDimitry Andric      bool operator!=(const directory_entry& rhs) const noexcept;             // removed  in C++20
221*bdd1243dSDimitry Andric      bool operator< (const directory_entry& rhs) const noexcept;             // removed  in C++20
222*bdd1243dSDimitry Andric      bool operator<=(const directory_entry& rhs) const noexcept;             // removed  in C++20
223*bdd1243dSDimitry Andric      bool operator> (const directory_entry& rhs) const noexcept;             // removed  in C++20
224*bdd1243dSDimitry Andric      bool operator>=(const directory_entry& rhs) const noexcept;             // removed  in C++20
225*bdd1243dSDimitry Andric      strong_ordering operator<=>(const directory_entry& rhs) const noexcept; // since C++20
226*bdd1243dSDimitry Andric
227*bdd1243dSDimitry Andric      template<class charT, class traits>
228*bdd1243dSDimitry Andric        friend basic_ostream<charT, traits>&
229*bdd1243dSDimitry Andric          operator<<(basic_ostream<charT, traits>& os, const directory_entry& d);
230*bdd1243dSDimitry Andric
231*bdd1243dSDimitry Andric    private:
232*bdd1243dSDimitry Andric      filesystem::path pathobject;        // exposition only
233*bdd1243dSDimitry Andric      friend class directory_iterator;    // exposition only
234*bdd1243dSDimitry Andric    };
2350b57cec5SDimitry Andric
2360b57cec5SDimitry Andric    class directory_iterator;
2370b57cec5SDimitry Andric
2380b57cec5SDimitry Andric    // enable directory_iterator range-based for statements
2390b57cec5SDimitry Andric    directory_iterator begin(directory_iterator iter) noexcept;
240349cc55cSDimitry Andric    directory_iterator end(directory_iterator) noexcept;
2410b57cec5SDimitry Andric
2420b57cec5SDimitry Andric    class recursive_directory_iterator;
2430b57cec5SDimitry Andric
2440b57cec5SDimitry Andric    // enable recursive_directory_iterator range-based for statements
2450b57cec5SDimitry Andric    recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
246349cc55cSDimitry Andric    recursive_directory_iterator end(recursive_directory_iterator) noexcept;
2470b57cec5SDimitry Andric
2480b57cec5SDimitry Andric    class file_status;
2490b57cec5SDimitry Andric
2500b57cec5SDimitry Andric    struct space_info
2510b57cec5SDimitry Andric    {
2520b57cec5SDimitry Andric      uintmax_t capacity;
2530b57cec5SDimitry Andric      uintmax_t free;
2540b57cec5SDimitry Andric      uintmax_t available;
255*bdd1243dSDimitry Andric
256*bdd1243dSDimitry Andric      friend bool operator==(const space_info&, const space_info&) = default; // C++20
2570b57cec5SDimitry Andric    };
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andric    enum class file_type;
2600b57cec5SDimitry Andric    enum class perms;
2610b57cec5SDimitry Andric    enum class perm_options;
2620b57cec5SDimitry Andric    enum class copy_options;
2630b57cec5SDimitry Andric    enum class directory_options;
2640b57cec5SDimitry Andric
2650b57cec5SDimitry Andric    typedef chrono::time_point<trivial-clock>  file_time_type;
2660b57cec5SDimitry Andric
2670b57cec5SDimitry Andric    // operational functions
2680b57cec5SDimitry Andric
2690b57cec5SDimitry Andric    path absolute(const path& p);
2700b57cec5SDimitry Andric    path absolute(const path& p, error_code &ec);
2710b57cec5SDimitry Andric
2720b57cec5SDimitry Andric    path canonical(const path& p);
2730b57cec5SDimitry Andric    path canonical(const path& p, error_code& ec);
2740b57cec5SDimitry Andric
2750b57cec5SDimitry Andric    void copy(const path& from, const path& to);
2760b57cec5SDimitry Andric    void copy(const path& from, const path& to, error_code& ec);
2770b57cec5SDimitry Andric    void copy(const path& from, const path& to, copy_options options);
2780b57cec5SDimitry Andric    void copy(const path& from, const path& to, copy_options options,
2790b57cec5SDimitry Andric                   error_code& ec);
2800b57cec5SDimitry Andric
2810b57cec5SDimitry Andric    bool copy_file(const path& from, const path& to);
2820b57cec5SDimitry Andric    bool copy_file(const path& from, const path& to, error_code& ec);
2830b57cec5SDimitry Andric    bool copy_file(const path& from, const path& to, copy_options option);
2840b57cec5SDimitry Andric    bool copy_file(const path& from, const path& to, copy_options option,
2850b57cec5SDimitry Andric                           error_code& ec);
2860b57cec5SDimitry Andric
2870b57cec5SDimitry Andric    void copy_symlink(const path& existing_symlink, const path& new_symlink);
2880b57cec5SDimitry Andric    void copy_symlink(const path& existing_symlink, const path& new_symlink,
2890b57cec5SDimitry Andric                              error_code& ec) noexcept;
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andric    bool create_directories(const path& p);
2920b57cec5SDimitry Andric    bool create_directories(const path& p, error_code& ec);
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andric    bool create_directory(const path& p);
2950b57cec5SDimitry Andric    bool create_directory(const path& p, error_code& ec) noexcept;
2960b57cec5SDimitry Andric
2970b57cec5SDimitry Andric    bool create_directory(const path& p, const path& attributes);
2980b57cec5SDimitry Andric    bool create_directory(const path& p, const path& attributes,
2990b57cec5SDimitry Andric                                  error_code& ec) noexcept;
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andric    void create_directory_symlink(const path& to, const path& new_symlink);
3020b57cec5SDimitry Andric    void create_directory_symlink(const path& to, const path& new_symlink,
3030b57cec5SDimitry Andric                                          error_code& ec) noexcept;
3040b57cec5SDimitry Andric
3050b57cec5SDimitry Andric    void create_hard_link(const path& to, const path& new_hard_link);
3060b57cec5SDimitry Andric    void create_hard_link(const path& to, const path& new_hard_link,
3070b57cec5SDimitry Andric                                  error_code& ec) noexcept;
3080b57cec5SDimitry Andric
3090b57cec5SDimitry Andric    void create_symlink(const path& to, const path& new_symlink);
3100b57cec5SDimitry Andric    void create_symlink(const path& to, const path& new_symlink,
3110b57cec5SDimitry Andric                                error_code& ec) noexcept;
3120b57cec5SDimitry Andric
3130b57cec5SDimitry Andric    path current_path();
3140b57cec5SDimitry Andric    path current_path(error_code& ec);
3150b57cec5SDimitry Andric    void current_path(const path& p);
3160b57cec5SDimitry Andric    void current_path(const path& p, error_code& ec) noexcept;
3170b57cec5SDimitry Andric
3180b57cec5SDimitry Andric    bool exists(file_status s) noexcept;
3190b57cec5SDimitry Andric    bool exists(const path& p);
3200b57cec5SDimitry Andric    bool exists(const path& p, error_code& ec) noexcept;
3210b57cec5SDimitry Andric
3220b57cec5SDimitry Andric    bool equivalent(const path& p1, const path& p2);
3230b57cec5SDimitry Andric    bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
3240b57cec5SDimitry Andric
3250b57cec5SDimitry Andric    uintmax_t    file_size(const path& p);
3260b57cec5SDimitry Andric    uintmax_t    file_size(const path& p, error_code& ec) noexcept;
3270b57cec5SDimitry Andric
3280b57cec5SDimitry Andric    uintmax_t    hard_link_count(const path& p);
3290b57cec5SDimitry Andric    uintmax_t    hard_link_count(const path& p, error_code& ec) noexcept;
3300b57cec5SDimitry Andric
3310b57cec5SDimitry Andric    bool is_block_file(file_status s) noexcept;
3320b57cec5SDimitry Andric    bool is_block_file(const path& p);
3330b57cec5SDimitry Andric    bool is_block_file(const path& p, error_code& ec) noexcept;
3340b57cec5SDimitry Andric
3350b57cec5SDimitry Andric    bool is_character_file(file_status s) noexcept;
3360b57cec5SDimitry Andric    bool is_character_file(const path& p);
3370b57cec5SDimitry Andric    bool is_character_file(const path& p, error_code& ec) noexcept;
3380b57cec5SDimitry Andric
3390b57cec5SDimitry Andric    bool is_directory(file_status s) noexcept;
3400b57cec5SDimitry Andric    bool is_directory(const path& p);
3410b57cec5SDimitry Andric    bool is_directory(const path& p, error_code& ec) noexcept;
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric    bool is_empty(const path& p);
3440b57cec5SDimitry Andric    bool is_empty(const path& p, error_code& ec) noexcept;
3450b57cec5SDimitry Andric
3460b57cec5SDimitry Andric    bool is_fifo(file_status s) noexcept;
3470b57cec5SDimitry Andric    bool is_fifo(const path& p);
3480b57cec5SDimitry Andric    bool is_fifo(const path& p, error_code& ec) noexcept;
3490b57cec5SDimitry Andric
3500b57cec5SDimitry Andric    bool is_other(file_status s) noexcept;
3510b57cec5SDimitry Andric    bool is_other(const path& p);
3520b57cec5SDimitry Andric    bool is_other(const path& p, error_code& ec) noexcept;
3530b57cec5SDimitry Andric
3540b57cec5SDimitry Andric    bool is_regular_file(file_status s) noexcept;
3550b57cec5SDimitry Andric    bool is_regular_file(const path& p);
3560b57cec5SDimitry Andric    bool is_regular_file(const path& p, error_code& ec) noexcept;
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andric    bool is_socket(file_status s) noexcept;
3590b57cec5SDimitry Andric    bool is_socket(const path& p);
3600b57cec5SDimitry Andric    bool is_socket(const path& p, error_code& ec) noexcept;
3610b57cec5SDimitry Andric
3620b57cec5SDimitry Andric    bool is_symlink(file_status s) noexcept;
3630b57cec5SDimitry Andric    bool is_symlink(const path& p);
3640b57cec5SDimitry Andric    bool is_symlink(const path& p, error_code& ec) noexcept;
3650b57cec5SDimitry Andric
3660b57cec5SDimitry Andric    file_time_type  last_write_time(const path& p);
3670b57cec5SDimitry Andric    file_time_type  last_write_time(const path& p, error_code& ec) noexcept;
3680b57cec5SDimitry Andric    void last_write_time(const path& p, file_time_type new_time);
3690b57cec5SDimitry Andric    void last_write_time(const path& p, file_time_type new_time,
3700b57cec5SDimitry Andric                                 error_code& ec) noexcept;
3710b57cec5SDimitry Andric
3720b57cec5SDimitry Andric    void permissions(const path& p, perms prms,
3730b57cec5SDimitry Andric                     perm_options opts=perm_options::replace);
3740b57cec5SDimitry Andric    void permissions(const path& p, perms prms, error_code& ec) noexcept;
3750b57cec5SDimitry Andric    void permissions(const path& p, perms prms, perm_options opts,
3760b57cec5SDimitry Andric                     error_code& ec);
3770b57cec5SDimitry Andric
3780b57cec5SDimitry Andric    path proximate(const path& p, error_code& ec);
3790b57cec5SDimitry Andric    path proximate(const path& p, const path& base = current_path());
3800b57cec5SDimitry Andric    path proximate(const path& p, const path& base, error_code &ec);
3810b57cec5SDimitry Andric
3820b57cec5SDimitry Andric    path read_symlink(const path& p);
3830b57cec5SDimitry Andric    path read_symlink(const path& p, error_code& ec);
3840b57cec5SDimitry Andric
3850b57cec5SDimitry Andric    path relative(const path& p, error_code& ec);
3860b57cec5SDimitry Andric    path relative(const path& p, const path& base=current_path());
3870b57cec5SDimitry Andric    path relative(const path& p, const path& base, error_code& ec);
3880b57cec5SDimitry Andric
3890b57cec5SDimitry Andric    bool remove(const path& p);
3900b57cec5SDimitry Andric    bool remove(const path& p, error_code& ec) noexcept;
3910b57cec5SDimitry Andric
3920b57cec5SDimitry Andric    uintmax_t    remove_all(const path& p);
3930b57cec5SDimitry Andric    uintmax_t    remove_all(const path& p, error_code& ec);
3940b57cec5SDimitry Andric
3950b57cec5SDimitry Andric    void rename(const path& from, const path& to);
3960b57cec5SDimitry Andric    void rename(const path& from, const path& to, error_code& ec) noexcept;
3970b57cec5SDimitry Andric
3980b57cec5SDimitry Andric    void resize_file(const path& p, uintmax_t size);
3990b57cec5SDimitry Andric    void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
4000b57cec5SDimitry Andric
4010b57cec5SDimitry Andric    space_info   space(const path& p);
4020b57cec5SDimitry Andric    space_info   space(const path& p, error_code& ec) noexcept;
4030b57cec5SDimitry Andric
4040b57cec5SDimitry Andric    file_status  status(const path& p);
4050b57cec5SDimitry Andric    file_status  status(const path& p, error_code& ec) noexcept;
4060b57cec5SDimitry Andric
4070b57cec5SDimitry Andric    bool status_known(file_status s) noexcept;
4080b57cec5SDimitry Andric
4090b57cec5SDimitry Andric    file_status  symlink_status(const path& p);
4100b57cec5SDimitry Andric    file_status  symlink_status(const path& p, error_code& ec) noexcept;
4110b57cec5SDimitry Andric
4120b57cec5SDimitry Andric    path temp_directory_path();
4130b57cec5SDimitry Andric    path temp_directory_path(error_code& ec);
4140b57cec5SDimitry Andric
4150b57cec5SDimitry Andric    path weakly_canonical(path const& p);
4160b57cec5SDimitry Andric    path weakly_canonical(path const& p, error_code& ec);
4170b57cec5SDimitry Andric
418349cc55cSDimitry Andric} // namespace std::filesystem
4190b57cec5SDimitry Andric
420349cc55cSDimitry Andrictemplate <>
421349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true;
422349cc55cSDimitry Andrictemplate <>
423349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true;
424349cc55cSDimitry Andric
425349cc55cSDimitry Andrictemplate <>
426349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true;
427349cc55cSDimitry Andrictemplate <>
428349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true;
4290b57cec5SDimitry Andric
4300b57cec5SDimitry Andric*/
4310b57cec5SDimitry Andric
43281ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
433fe6060f1SDimitry Andric#include <__config>
4340eae32dcSDimitry Andric#include <__filesystem/copy_options.h>
4350eae32dcSDimitry Andric#include <__filesystem/directory_entry.h>
4360eae32dcSDimitry Andric#include <__filesystem/directory_iterator.h>
4370eae32dcSDimitry Andric#include <__filesystem/directory_options.h>
4380eae32dcSDimitry Andric#include <__filesystem/file_status.h>
4390eae32dcSDimitry Andric#include <__filesystem/file_time_type.h>
4400eae32dcSDimitry Andric#include <__filesystem/file_type.h>
4410eae32dcSDimitry Andric#include <__filesystem/filesystem_error.h>
4420eae32dcSDimitry Andric#include <__filesystem/operations.h>
4430eae32dcSDimitry Andric#include <__filesystem/path.h>
44404eeddc0SDimitry Andric#include <__filesystem/path_iterator.h>
4450eae32dcSDimitry Andric#include <__filesystem/perm_options.h>
4460eae32dcSDimitry Andric#include <__filesystem/perms.h>
4470eae32dcSDimitry Andric#include <__filesystem/recursive_directory_iterator.h>
4480eae32dcSDimitry Andric#include <__filesystem/space_info.h>
4490eae32dcSDimitry Andric#include <__filesystem/u8path.h>
4500b57cec5SDimitry Andric#include <version>
4510b57cec5SDimitry Andric
45281ad6265SDimitry Andric// standard-mandated includes
453*bdd1243dSDimitry Andric
454*bdd1243dSDimitry Andric// [fs.filesystem.syn]
45581ad6265SDimitry Andric#include <compare>
45681ad6265SDimitry Andric
457e8d8bef9SDimitry Andric#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
45881ad6265SDimitry Andric# error "The <filesystem> library is not supported since libc++ has been configured without support for a filesystem."
459e8d8bef9SDimitry Andric#endif
460e8d8bef9SDimitry Andric
4610b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4620b57cec5SDimitry Andric#  pragma GCC system_header
4630b57cec5SDimitry Andric#endif
4640b57cec5SDimitry Andric
465*bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
466*bdd1243dSDimitry Andric#  include <concepts>
467*bdd1243dSDimitry Andric#endif
468*bdd1243dSDimitry Andric
4690b57cec5SDimitry Andric#endif // _LIBCPP_FILESYSTEM
470