xref: /aosp_15_r20/external/libcxx/include/filesystem (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- filesystem -------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_FILESYSTEM
11*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_FILESYSTEM
12*58b9f456SAndroid Build Coastguard Worker/*
13*58b9f456SAndroid Build Coastguard Worker    filesystem synopsis
14*58b9f456SAndroid Build Coastguard Worker
15*58b9f456SAndroid Build Coastguard Worker    namespace std { namespace filesystem {
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Worker    class path;
18*58b9f456SAndroid Build Coastguard Worker
19*58b9f456SAndroid Build Coastguard Worker    void swap(path& lhs, path& rhs) noexcept;
20*58b9f456SAndroid Build Coastguard Worker    size_t hash_value(const path& p) noexcept;
21*58b9f456SAndroid Build Coastguard Worker
22*58b9f456SAndroid Build Coastguard Worker    bool operator==(const path& lhs, const path& rhs) noexcept;
23*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const path& lhs, const path& rhs) noexcept;
24*58b9f456SAndroid Build Coastguard Worker    bool operator< (const path& lhs, const path& rhs) noexcept;
25*58b9f456SAndroid Build Coastguard Worker    bool operator<=(const path& lhs, const path& rhs) noexcept;
26*58b9f456SAndroid Build Coastguard Worker    bool operator> (const path& lhs, const path& rhs) noexcept;
27*58b9f456SAndroid Build Coastguard Worker    bool operator>=(const path& lhs, const path& rhs) noexcept;
28*58b9f456SAndroid Build Coastguard Worker
29*58b9f456SAndroid Build Coastguard Worker    path operator/ (const path& lhs, const path& rhs);
30*58b9f456SAndroid Build Coastguard Worker
31*58b9f456SAndroid Build Coastguard Worker    // fs.path.io operators are friends of path.
32*58b9f456SAndroid Build Coastguard Worker    template <class charT, class traits>
33*58b9f456SAndroid Build Coastguard Worker    friend basic_ostream<charT, traits>&
34*58b9f456SAndroid Build Coastguard Worker    operator<<(basic_ostream<charT, traits>& os, const path& p);
35*58b9f456SAndroid Build Coastguard Worker
36*58b9f456SAndroid Build Coastguard Worker    template <class charT, class traits>
37*58b9f456SAndroid Build Coastguard Worker    friend basic_istream<charT, traits>&
38*58b9f456SAndroid Build Coastguard Worker    operator>>(basic_istream<charT, traits>& is, path& p);
39*58b9f456SAndroid Build Coastguard Worker
40*58b9f456SAndroid Build Coastguard Worker    template <class Source>
41*58b9f456SAndroid Build Coastguard Worker      path u8path(const Source& source);
42*58b9f456SAndroid Build Coastguard Worker    template <class InputIterator>
43*58b9f456SAndroid Build Coastguard Worker      path u8path(InputIterator first, InputIterator last);
44*58b9f456SAndroid Build Coastguard Worker
45*58b9f456SAndroid Build Coastguard Worker    class filesystem_error;
46*58b9f456SAndroid Build Coastguard Worker    class directory_entry;
47*58b9f456SAndroid Build Coastguard Worker
48*58b9f456SAndroid Build Coastguard Worker    class directory_iterator;
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Worker    // enable directory_iterator range-based for statements
51*58b9f456SAndroid Build Coastguard Worker    directory_iterator begin(directory_iterator iter) noexcept;
52*58b9f456SAndroid Build Coastguard Worker    directory_iterator end(const directory_iterator&) noexcept;
53*58b9f456SAndroid Build Coastguard Worker
54*58b9f456SAndroid Build Coastguard Worker    class recursive_directory_iterator;
55*58b9f456SAndroid Build Coastguard Worker
56*58b9f456SAndroid Build Coastguard Worker    // enable recursive_directory_iterator range-based for statements
57*58b9f456SAndroid Build Coastguard Worker    recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
58*58b9f456SAndroid Build Coastguard Worker    recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
59*58b9f456SAndroid Build Coastguard Worker
60*58b9f456SAndroid Build Coastguard Worker    class file_status;
61*58b9f456SAndroid Build Coastguard Worker
62*58b9f456SAndroid Build Coastguard Worker    struct space_info
63*58b9f456SAndroid Build Coastguard Worker    {
64*58b9f456SAndroid Build Coastguard Worker      uintmax_t capacity;
65*58b9f456SAndroid Build Coastguard Worker      uintmax_t free;
66*58b9f456SAndroid Build Coastguard Worker      uintmax_t available;
67*58b9f456SAndroid Build Coastguard Worker    };
68*58b9f456SAndroid Build Coastguard Worker
69*58b9f456SAndroid Build Coastguard Worker    enum class file_type;
70*58b9f456SAndroid Build Coastguard Worker    enum class perms;
71*58b9f456SAndroid Build Coastguard Worker    enum class perm_options;
72*58b9f456SAndroid Build Coastguard Worker    enum class copy_options;
73*58b9f456SAndroid Build Coastguard Worker    enum class directory_options;
74*58b9f456SAndroid Build Coastguard Worker
75*58b9f456SAndroid Build Coastguard Worker    typedef chrono::time_point<trivial-clock>  file_time_type;
76*58b9f456SAndroid Build Coastguard Worker
77*58b9f456SAndroid Build Coastguard Worker    // operational functions
78*58b9f456SAndroid Build Coastguard Worker
79*58b9f456SAndroid Build Coastguard Worker    path absolute(const path& p);
80*58b9f456SAndroid Build Coastguard Worker    path absolute(const path& p, error_code &ec);
81*58b9f456SAndroid Build Coastguard Worker
82*58b9f456SAndroid Build Coastguard Worker    path canonical(const path& p);
83*58b9f456SAndroid Build Coastguard Worker    path canonical(const path& p, error_code& ec);
84*58b9f456SAndroid Build Coastguard Worker
85*58b9f456SAndroid Build Coastguard Worker    void copy(const path& from, const path& to);
86*58b9f456SAndroid Build Coastguard Worker    void copy(const path& from, const path& to, error_code& ec);
87*58b9f456SAndroid Build Coastguard Worker    void copy(const path& from, const path& to, copy_options options);
88*58b9f456SAndroid Build Coastguard Worker    void copy(const path& from, const path& to, copy_options options,
89*58b9f456SAndroid Build Coastguard Worker                   error_code& ec);
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker    bool copy_file(const path& from, const path& to);
92*58b9f456SAndroid Build Coastguard Worker    bool copy_file(const path& from, const path& to, error_code& ec);
93*58b9f456SAndroid Build Coastguard Worker    bool copy_file(const path& from, const path& to, copy_options option);
94*58b9f456SAndroid Build Coastguard Worker    bool copy_file(const path& from, const path& to, copy_options option,
95*58b9f456SAndroid Build Coastguard Worker                           error_code& ec);
96*58b9f456SAndroid Build Coastguard Worker
97*58b9f456SAndroid Build Coastguard Worker    void copy_symlink(const path& existing_symlink, const path& new_symlink);
98*58b9f456SAndroid Build Coastguard Worker    void copy_symlink(const path& existing_symlink, const path& new_symlink,
99*58b9f456SAndroid Build Coastguard Worker                              error_code& ec) noexcept;
100*58b9f456SAndroid Build Coastguard Worker
101*58b9f456SAndroid Build Coastguard Worker    bool create_directories(const path& p);
102*58b9f456SAndroid Build Coastguard Worker    bool create_directories(const path& p, error_code& ec);
103*58b9f456SAndroid Build Coastguard Worker
104*58b9f456SAndroid Build Coastguard Worker    bool create_directory(const path& p);
105*58b9f456SAndroid Build Coastguard Worker    bool create_directory(const path& p, error_code& ec) noexcept;
106*58b9f456SAndroid Build Coastguard Worker
107*58b9f456SAndroid Build Coastguard Worker    bool create_directory(const path& p, const path& attributes);
108*58b9f456SAndroid Build Coastguard Worker    bool create_directory(const path& p, const path& attributes,
109*58b9f456SAndroid Build Coastguard Worker                                  error_code& ec) noexcept;
110*58b9f456SAndroid Build Coastguard Worker
111*58b9f456SAndroid Build Coastguard Worker    void create_directory_symlink(const path& to, const path& new_symlink);
112*58b9f456SAndroid Build Coastguard Worker    void create_directory_symlink(const path& to, const path& new_symlink,
113*58b9f456SAndroid Build Coastguard Worker                                          error_code& ec) noexcept;
114*58b9f456SAndroid Build Coastguard Worker
115*58b9f456SAndroid Build Coastguard Worker    void create_hard_link(const path& to, const path& new_hard_link);
116*58b9f456SAndroid Build Coastguard Worker    void create_hard_link(const path& to, const path& new_hard_link,
117*58b9f456SAndroid Build Coastguard Worker                                  error_code& ec) noexcept;
118*58b9f456SAndroid Build Coastguard Worker
119*58b9f456SAndroid Build Coastguard Worker    void create_symlink(const path& to, const path& new_symlink);
120*58b9f456SAndroid Build Coastguard Worker    void create_symlink(const path& to, const path& new_symlink,
121*58b9f456SAndroid Build Coastguard Worker                                error_code& ec) noexcept;
122*58b9f456SAndroid Build Coastguard Worker
123*58b9f456SAndroid Build Coastguard Worker    path current_path();
124*58b9f456SAndroid Build Coastguard Worker    path current_path(error_code& ec);
125*58b9f456SAndroid Build Coastguard Worker    void current_path(const path& p);
126*58b9f456SAndroid Build Coastguard Worker    void current_path(const path& p, error_code& ec) noexcept;
127*58b9f456SAndroid Build Coastguard Worker
128*58b9f456SAndroid Build Coastguard Worker    bool exists(file_status s) noexcept;
129*58b9f456SAndroid Build Coastguard Worker    bool exists(const path& p);
130*58b9f456SAndroid Build Coastguard Worker    bool exists(const path& p, error_code& ec) noexcept;
131*58b9f456SAndroid Build Coastguard Worker
132*58b9f456SAndroid Build Coastguard Worker    bool equivalent(const path& p1, const path& p2);
133*58b9f456SAndroid Build Coastguard Worker    bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
134*58b9f456SAndroid Build Coastguard Worker
135*58b9f456SAndroid Build Coastguard Worker    uintmax_t    file_size(const path& p);
136*58b9f456SAndroid Build Coastguard Worker    uintmax_t    file_size(const path& p, error_code& ec) noexcept;
137*58b9f456SAndroid Build Coastguard Worker
138*58b9f456SAndroid Build Coastguard Worker    uintmax_t    hard_link_count(const path& p);
139*58b9f456SAndroid Build Coastguard Worker    uintmax_t    hard_link_count(const path& p, error_code& ec) noexcept;
140*58b9f456SAndroid Build Coastguard Worker
141*58b9f456SAndroid Build Coastguard Worker    bool is_block_file(file_status s) noexcept;
142*58b9f456SAndroid Build Coastguard Worker    bool is_block_file(const path& p);
143*58b9f456SAndroid Build Coastguard Worker    bool is_block_file(const path& p, error_code& ec) noexcept;
144*58b9f456SAndroid Build Coastguard Worker
145*58b9f456SAndroid Build Coastguard Worker    bool is_character_file(file_status s) noexcept;
146*58b9f456SAndroid Build Coastguard Worker    bool is_character_file(const path& p);
147*58b9f456SAndroid Build Coastguard Worker    bool is_character_file(const path& p, error_code& ec) noexcept;
148*58b9f456SAndroid Build Coastguard Worker
149*58b9f456SAndroid Build Coastguard Worker    bool is_directory(file_status s) noexcept;
150*58b9f456SAndroid Build Coastguard Worker    bool is_directory(const path& p);
151*58b9f456SAndroid Build Coastguard Worker    bool is_directory(const path& p, error_code& ec) noexcept;
152*58b9f456SAndroid Build Coastguard Worker
153*58b9f456SAndroid Build Coastguard Worker    bool is_empty(const path& p);
154*58b9f456SAndroid Build Coastguard Worker    bool is_empty(const path& p, error_code& ec) noexcept;
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Worker    bool is_fifo(file_status s) noexcept;
157*58b9f456SAndroid Build Coastguard Worker    bool is_fifo(const path& p);
158*58b9f456SAndroid Build Coastguard Worker    bool is_fifo(const path& p, error_code& ec) noexcept;
159*58b9f456SAndroid Build Coastguard Worker
160*58b9f456SAndroid Build Coastguard Worker    bool is_other(file_status s) noexcept;
161*58b9f456SAndroid Build Coastguard Worker    bool is_other(const path& p);
162*58b9f456SAndroid Build Coastguard Worker    bool is_other(const path& p, error_code& ec) noexcept;
163*58b9f456SAndroid Build Coastguard Worker
164*58b9f456SAndroid Build Coastguard Worker    bool is_regular_file(file_status s) noexcept;
165*58b9f456SAndroid Build Coastguard Worker    bool is_regular_file(const path& p);
166*58b9f456SAndroid Build Coastguard Worker    bool is_regular_file(const path& p, error_code& ec) noexcept;
167*58b9f456SAndroid Build Coastguard Worker
168*58b9f456SAndroid Build Coastguard Worker    bool is_socket(file_status s) noexcept;
169*58b9f456SAndroid Build Coastguard Worker    bool is_socket(const path& p);
170*58b9f456SAndroid Build Coastguard Worker    bool is_socket(const path& p, error_code& ec) noexcept;
171*58b9f456SAndroid Build Coastguard Worker
172*58b9f456SAndroid Build Coastguard Worker    bool is_symlink(file_status s) noexcept;
173*58b9f456SAndroid Build Coastguard Worker    bool is_symlink(const path& p);
174*58b9f456SAndroid Build Coastguard Worker    bool is_symlink(const path& p, error_code& ec) noexcept;
175*58b9f456SAndroid Build Coastguard Worker
176*58b9f456SAndroid Build Coastguard Worker    file_time_type  last_write_time(const path& p);
177*58b9f456SAndroid Build Coastguard Worker    file_time_type  last_write_time(const path& p, error_code& ec) noexcept;
178*58b9f456SAndroid Build Coastguard Worker    void last_write_time(const path& p, file_time_type new_time);
179*58b9f456SAndroid Build Coastguard Worker    void last_write_time(const path& p, file_time_type new_time,
180*58b9f456SAndroid Build Coastguard Worker                                 error_code& ec) noexcept;
181*58b9f456SAndroid Build Coastguard Worker
182*58b9f456SAndroid Build Coastguard Worker    void permissions(const path& p, perms prms,
183*58b9f456SAndroid Build Coastguard Worker                     perm_options opts=perm_options::replace);
184*58b9f456SAndroid Build Coastguard Worker    void permissions(const path& p, perms prms, error_code& ec) noexcept;
185*58b9f456SAndroid Build Coastguard Worker    void permissions(const path& p, perms prms, perm_options opts,
186*58b9f456SAndroid Build Coastguard Worker                     error_code& ec);
187*58b9f456SAndroid Build Coastguard Worker
188*58b9f456SAndroid Build Coastguard Worker    path proximate(const path& p, error_code& ec);
189*58b9f456SAndroid Build Coastguard Worker    path proximate(const path& p, const path& base = current_path());
190*58b9f456SAndroid Build Coastguard Worker    path proximate(const path& p, const path& base, error_code &ec);
191*58b9f456SAndroid Build Coastguard Worker
192*58b9f456SAndroid Build Coastguard Worker    path read_symlink(const path& p);
193*58b9f456SAndroid Build Coastguard Worker    path read_symlink(const path& p, error_code& ec);
194*58b9f456SAndroid Build Coastguard Worker
195*58b9f456SAndroid Build Coastguard Worker    path relative(const path& p, error_code& ec);
196*58b9f456SAndroid Build Coastguard Worker    path relative(const path& p, const path& base=current_path());
197*58b9f456SAndroid Build Coastguard Worker    path relative(const path& p, const path& base, error_code& ec);
198*58b9f456SAndroid Build Coastguard Worker
199*58b9f456SAndroid Build Coastguard Worker    bool remove(const path& p);
200*58b9f456SAndroid Build Coastguard Worker    bool remove(const path& p, error_code& ec) noexcept;
201*58b9f456SAndroid Build Coastguard Worker
202*58b9f456SAndroid Build Coastguard Worker    uintmax_t    remove_all(const path& p);
203*58b9f456SAndroid Build Coastguard Worker    uintmax_t    remove_all(const path& p, error_code& ec);
204*58b9f456SAndroid Build Coastguard Worker
205*58b9f456SAndroid Build Coastguard Worker    void rename(const path& from, const path& to);
206*58b9f456SAndroid Build Coastguard Worker    void rename(const path& from, const path& to, error_code& ec) noexcept;
207*58b9f456SAndroid Build Coastguard Worker
208*58b9f456SAndroid Build Coastguard Worker    void resize_file(const path& p, uintmax_t size);
209*58b9f456SAndroid Build Coastguard Worker    void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
210*58b9f456SAndroid Build Coastguard Worker
211*58b9f456SAndroid Build Coastguard Worker    space_info   space(const path& p);
212*58b9f456SAndroid Build Coastguard Worker    space_info   space(const path& p, error_code& ec) noexcept;
213*58b9f456SAndroid Build Coastguard Worker
214*58b9f456SAndroid Build Coastguard Worker    file_status  status(const path& p);
215*58b9f456SAndroid Build Coastguard Worker    file_status  status(const path& p, error_code& ec) noexcept;
216*58b9f456SAndroid Build Coastguard Worker
217*58b9f456SAndroid Build Coastguard Worker    bool status_known(file_status s) noexcept;
218*58b9f456SAndroid Build Coastguard Worker
219*58b9f456SAndroid Build Coastguard Worker    file_status  symlink_status(const path& p);
220*58b9f456SAndroid Build Coastguard Worker    file_status  symlink_status(const path& p, error_code& ec) noexcept;
221*58b9f456SAndroid Build Coastguard Worker
222*58b9f456SAndroid Build Coastguard Worker    path temp_directory_path();
223*58b9f456SAndroid Build Coastguard Worker    path temp_directory_path(error_code& ec);
224*58b9f456SAndroid Build Coastguard Worker
225*58b9f456SAndroid Build Coastguard Worker    path weakly_canonical(path const& p);
226*58b9f456SAndroid Build Coastguard Worker    path weakly_canonical(path const& p, error_code& ec);
227*58b9f456SAndroid Build Coastguard Worker
228*58b9f456SAndroid Build Coastguard Worker
229*58b9f456SAndroid Build Coastguard Worker} }  // namespaces std::filesystem
230*58b9f456SAndroid Build Coastguard Worker
231*58b9f456SAndroid Build Coastguard Worker*/
232*58b9f456SAndroid Build Coastguard Worker
233*58b9f456SAndroid Build Coastguard Worker#include <__config>
234*58b9f456SAndroid Build Coastguard Worker#include <cstddef>
235*58b9f456SAndroid Build Coastguard Worker#include <cstdlib>
236*58b9f456SAndroid Build Coastguard Worker#include <chrono>
237*58b9f456SAndroid Build Coastguard Worker#include <iterator>
238*58b9f456SAndroid Build Coastguard Worker#include <iosfwd>
239*58b9f456SAndroid Build Coastguard Worker#include <locale>
240*58b9f456SAndroid Build Coastguard Worker#include <memory>
241*58b9f456SAndroid Build Coastguard Worker#include <stack>
242*58b9f456SAndroid Build Coastguard Worker#include <string>
243*58b9f456SAndroid Build Coastguard Worker#include <system_error>
244*58b9f456SAndroid Build Coastguard Worker#include <utility>
245*58b9f456SAndroid Build Coastguard Worker#include <iomanip> // for quoted
246*58b9f456SAndroid Build Coastguard Worker#include <string_view>
247*58b9f456SAndroid Build Coastguard Worker#include <version>
248*58b9f456SAndroid Build Coastguard Worker
249*58b9f456SAndroid Build Coastguard Worker#include <__debug>
250*58b9f456SAndroid Build Coastguard Worker
251*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
252*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
253*58b9f456SAndroid Build Coastguard Worker#endif
254*58b9f456SAndroid Build Coastguard Worker
255*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
256*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
257*58b9f456SAndroid Build Coastguard Worker
258*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
259*58b9f456SAndroid Build Coastguard Worker
260*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
261*58b9f456SAndroid Build Coastguard Worker
262*58b9f456SAndroid Build Coastguard Workertypedef chrono::time_point<_FilesystemClock> file_time_type;
263*58b9f456SAndroid Build Coastguard Worker
264*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TYPE_VIS space_info {
265*58b9f456SAndroid Build Coastguard Worker  uintmax_t capacity;
266*58b9f456SAndroid Build Coastguard Worker  uintmax_t free;
267*58b9f456SAndroid Build Coastguard Worker  uintmax_t available;
268*58b9f456SAndroid Build Coastguard Worker};
269*58b9f456SAndroid Build Coastguard Worker
270*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS file_type : signed char {
271*58b9f456SAndroid Build Coastguard Worker  none = 0,
272*58b9f456SAndroid Build Coastguard Worker  not_found = -1,
273*58b9f456SAndroid Build Coastguard Worker  regular = 1,
274*58b9f456SAndroid Build Coastguard Worker  directory = 2,
275*58b9f456SAndroid Build Coastguard Worker  symlink = 3,
276*58b9f456SAndroid Build Coastguard Worker  block = 4,
277*58b9f456SAndroid Build Coastguard Worker  character = 5,
278*58b9f456SAndroid Build Coastguard Worker  fifo = 6,
279*58b9f456SAndroid Build Coastguard Worker  socket = 7,
280*58b9f456SAndroid Build Coastguard Worker  unknown = 8
281*58b9f456SAndroid Build Coastguard Worker};
282*58b9f456SAndroid Build Coastguard Worker
283*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS perms : unsigned {
284*58b9f456SAndroid Build Coastguard Worker  none = 0,
285*58b9f456SAndroid Build Coastguard Worker
286*58b9f456SAndroid Build Coastguard Worker  owner_read = 0400,
287*58b9f456SAndroid Build Coastguard Worker  owner_write = 0200,
288*58b9f456SAndroid Build Coastguard Worker  owner_exec = 0100,
289*58b9f456SAndroid Build Coastguard Worker  owner_all = 0700,
290*58b9f456SAndroid Build Coastguard Worker
291*58b9f456SAndroid Build Coastguard Worker  group_read = 040,
292*58b9f456SAndroid Build Coastguard Worker  group_write = 020,
293*58b9f456SAndroid Build Coastguard Worker  group_exec = 010,
294*58b9f456SAndroid Build Coastguard Worker  group_all = 070,
295*58b9f456SAndroid Build Coastguard Worker
296*58b9f456SAndroid Build Coastguard Worker  others_read = 04,
297*58b9f456SAndroid Build Coastguard Worker  others_write = 02,
298*58b9f456SAndroid Build Coastguard Worker  others_exec = 01,
299*58b9f456SAndroid Build Coastguard Worker  others_all = 07,
300*58b9f456SAndroid Build Coastguard Worker
301*58b9f456SAndroid Build Coastguard Worker  all = 0777,
302*58b9f456SAndroid Build Coastguard Worker
303*58b9f456SAndroid Build Coastguard Worker  set_uid = 04000,
304*58b9f456SAndroid Build Coastguard Worker  set_gid = 02000,
305*58b9f456SAndroid Build Coastguard Worker  sticky_bit = 01000,
306*58b9f456SAndroid Build Coastguard Worker  mask = 07777,
307*58b9f456SAndroid Build Coastguard Worker  unknown = 0xFFFF,
308*58b9f456SAndroid Build Coastguard Worker};
309*58b9f456SAndroid Build Coastguard Worker
310*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
311*58b9f456SAndroid Build Coastguard Workerinline constexpr perms operator&(perms _LHS, perms _RHS) {
312*58b9f456SAndroid Build Coastguard Worker  return static_cast<perms>(static_cast<unsigned>(_LHS) &
313*58b9f456SAndroid Build Coastguard Worker                            static_cast<unsigned>(_RHS));
314*58b9f456SAndroid Build Coastguard Worker}
315*58b9f456SAndroid Build Coastguard Worker
316*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
317*58b9f456SAndroid Build Coastguard Workerinline constexpr perms operator|(perms _LHS, perms _RHS) {
318*58b9f456SAndroid Build Coastguard Worker  return static_cast<perms>(static_cast<unsigned>(_LHS) |
319*58b9f456SAndroid Build Coastguard Worker                            static_cast<unsigned>(_RHS));
320*58b9f456SAndroid Build Coastguard Worker}
321*58b9f456SAndroid Build Coastguard Worker
322*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
323*58b9f456SAndroid Build Coastguard Workerinline constexpr perms operator^(perms _LHS, perms _RHS) {
324*58b9f456SAndroid Build Coastguard Worker  return static_cast<perms>(static_cast<unsigned>(_LHS) ^
325*58b9f456SAndroid Build Coastguard Worker                            static_cast<unsigned>(_RHS));
326*58b9f456SAndroid Build Coastguard Worker}
327*58b9f456SAndroid Build Coastguard Worker
328*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
329*58b9f456SAndroid Build Coastguard Workerinline constexpr perms operator~(perms _LHS) {
330*58b9f456SAndroid Build Coastguard Worker  return static_cast<perms>(~static_cast<unsigned>(_LHS));
331*58b9f456SAndroid Build Coastguard Worker}
332*58b9f456SAndroid Build Coastguard Worker
333*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
334*58b9f456SAndroid Build Coastguard Workerinline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; }
335*58b9f456SAndroid Build Coastguard Worker
336*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
337*58b9f456SAndroid Build Coastguard Workerinline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; }
338*58b9f456SAndroid Build Coastguard Worker
339*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
340*58b9f456SAndroid Build Coastguard Workerinline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; }
341*58b9f456SAndroid Build Coastguard Worker
342*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS perm_options : unsigned char {
343*58b9f456SAndroid Build Coastguard Worker  replace = 1,
344*58b9f456SAndroid Build Coastguard Worker  add = 2,
345*58b9f456SAndroid Build Coastguard Worker  remove = 4,
346*58b9f456SAndroid Build Coastguard Worker  nofollow = 8
347*58b9f456SAndroid Build Coastguard Worker};
348*58b9f456SAndroid Build Coastguard Worker
349*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
350*58b9f456SAndroid Build Coastguard Workerinline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) {
351*58b9f456SAndroid Build Coastguard Worker  return static_cast<perm_options>(static_cast<unsigned>(_LHS) &
352*58b9f456SAndroid Build Coastguard Worker                                   static_cast<unsigned>(_RHS));
353*58b9f456SAndroid Build Coastguard Worker}
354*58b9f456SAndroid Build Coastguard Worker
355*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
356*58b9f456SAndroid Build Coastguard Workerinline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) {
357*58b9f456SAndroid Build Coastguard Worker  return static_cast<perm_options>(static_cast<unsigned>(_LHS) |
358*58b9f456SAndroid Build Coastguard Worker                                   static_cast<unsigned>(_RHS));
359*58b9f456SAndroid Build Coastguard Worker}
360*58b9f456SAndroid Build Coastguard Worker
361*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
362*58b9f456SAndroid Build Coastguard Workerinline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) {
363*58b9f456SAndroid Build Coastguard Worker  return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^
364*58b9f456SAndroid Build Coastguard Worker                                   static_cast<unsigned>(_RHS));
365*58b9f456SAndroid Build Coastguard Worker}
366*58b9f456SAndroid Build Coastguard Worker
367*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
368*58b9f456SAndroid Build Coastguard Workerinline constexpr perm_options operator~(perm_options _LHS) {
369*58b9f456SAndroid Build Coastguard Worker  return static_cast<perm_options>(~static_cast<unsigned>(_LHS));
370*58b9f456SAndroid Build Coastguard Worker}
371*58b9f456SAndroid Build Coastguard Worker
372*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
373*58b9f456SAndroid Build Coastguard Workerinline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) {
374*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS & _RHS;
375*58b9f456SAndroid Build Coastguard Worker}
376*58b9f456SAndroid Build Coastguard Worker
377*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
378*58b9f456SAndroid Build Coastguard Workerinline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) {
379*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS | _RHS;
380*58b9f456SAndroid Build Coastguard Worker}
381*58b9f456SAndroid Build Coastguard Worker
382*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
383*58b9f456SAndroid Build Coastguard Workerinline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) {
384*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS ^ _RHS;
385*58b9f456SAndroid Build Coastguard Worker}
386*58b9f456SAndroid Build Coastguard Worker
387*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS copy_options : unsigned short {
388*58b9f456SAndroid Build Coastguard Worker  none = 0,
389*58b9f456SAndroid Build Coastguard Worker  skip_existing = 1,
390*58b9f456SAndroid Build Coastguard Worker  overwrite_existing = 2,
391*58b9f456SAndroid Build Coastguard Worker  update_existing = 4,
392*58b9f456SAndroid Build Coastguard Worker  recursive = 8,
393*58b9f456SAndroid Build Coastguard Worker  copy_symlinks = 16,
394*58b9f456SAndroid Build Coastguard Worker  skip_symlinks = 32,
395*58b9f456SAndroid Build Coastguard Worker  directories_only = 64,
396*58b9f456SAndroid Build Coastguard Worker  create_symlinks = 128,
397*58b9f456SAndroid Build Coastguard Worker  create_hard_links = 256,
398*58b9f456SAndroid Build Coastguard Worker  __in_recursive_copy = 512,
399*58b9f456SAndroid Build Coastguard Worker};
400*58b9f456SAndroid Build Coastguard Worker
401*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
402*58b9f456SAndroid Build Coastguard Workerinline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) {
403*58b9f456SAndroid Build Coastguard Worker  return static_cast<copy_options>(static_cast<unsigned short>(_LHS) &
404*58b9f456SAndroid Build Coastguard Worker                                   static_cast<unsigned short>(_RHS));
405*58b9f456SAndroid Build Coastguard Worker}
406*58b9f456SAndroid Build Coastguard Worker
407*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
408*58b9f456SAndroid Build Coastguard Workerinline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) {
409*58b9f456SAndroid Build Coastguard Worker  return static_cast<copy_options>(static_cast<unsigned short>(_LHS) |
410*58b9f456SAndroid Build Coastguard Worker                                   static_cast<unsigned short>(_RHS));
411*58b9f456SAndroid Build Coastguard Worker}
412*58b9f456SAndroid Build Coastguard Worker
413*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
414*58b9f456SAndroid Build Coastguard Workerinline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) {
415*58b9f456SAndroid Build Coastguard Worker  return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^
416*58b9f456SAndroid Build Coastguard Worker                                   static_cast<unsigned short>(_RHS));
417*58b9f456SAndroid Build Coastguard Worker}
418*58b9f456SAndroid Build Coastguard Worker
419*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
420*58b9f456SAndroid Build Coastguard Workerinline constexpr copy_options operator~(copy_options _LHS) {
421*58b9f456SAndroid Build Coastguard Worker  return static_cast<copy_options>(~static_cast<unsigned short>(_LHS));
422*58b9f456SAndroid Build Coastguard Worker}
423*58b9f456SAndroid Build Coastguard Worker
424*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
425*58b9f456SAndroid Build Coastguard Workerinline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) {
426*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS & _RHS;
427*58b9f456SAndroid Build Coastguard Worker}
428*58b9f456SAndroid Build Coastguard Worker
429*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
430*58b9f456SAndroid Build Coastguard Workerinline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) {
431*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS | _RHS;
432*58b9f456SAndroid Build Coastguard Worker}
433*58b9f456SAndroid Build Coastguard Worker
434*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
435*58b9f456SAndroid Build Coastguard Workerinline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) {
436*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS ^ _RHS;
437*58b9f456SAndroid Build Coastguard Worker}
438*58b9f456SAndroid Build Coastguard Worker
439*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS directory_options : unsigned char {
440*58b9f456SAndroid Build Coastguard Worker  none = 0,
441*58b9f456SAndroid Build Coastguard Worker  follow_directory_symlink = 1,
442*58b9f456SAndroid Build Coastguard Worker  skip_permission_denied = 2
443*58b9f456SAndroid Build Coastguard Worker};
444*58b9f456SAndroid Build Coastguard Worker
445*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
446*58b9f456SAndroid Build Coastguard Workerinline constexpr directory_options operator&(directory_options _LHS,
447*58b9f456SAndroid Build Coastguard Worker                                             directory_options _RHS) {
448*58b9f456SAndroid Build Coastguard Worker  return static_cast<directory_options>(static_cast<unsigned char>(_LHS) &
449*58b9f456SAndroid Build Coastguard Worker                                        static_cast<unsigned char>(_RHS));
450*58b9f456SAndroid Build Coastguard Worker}
451*58b9f456SAndroid Build Coastguard Worker
452*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
453*58b9f456SAndroid Build Coastguard Workerinline constexpr directory_options operator|(directory_options _LHS,
454*58b9f456SAndroid Build Coastguard Worker                                             directory_options _RHS) {
455*58b9f456SAndroid Build Coastguard Worker  return static_cast<directory_options>(static_cast<unsigned char>(_LHS) |
456*58b9f456SAndroid Build Coastguard Worker                                        static_cast<unsigned char>(_RHS));
457*58b9f456SAndroid Build Coastguard Worker}
458*58b9f456SAndroid Build Coastguard Worker
459*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
460*58b9f456SAndroid Build Coastguard Workerinline constexpr directory_options operator^(directory_options _LHS,
461*58b9f456SAndroid Build Coastguard Worker                                             directory_options _RHS) {
462*58b9f456SAndroid Build Coastguard Worker  return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^
463*58b9f456SAndroid Build Coastguard Worker                                        static_cast<unsigned char>(_RHS));
464*58b9f456SAndroid Build Coastguard Worker}
465*58b9f456SAndroid Build Coastguard Worker
466*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
467*58b9f456SAndroid Build Coastguard Workerinline constexpr directory_options operator~(directory_options _LHS) {
468*58b9f456SAndroid Build Coastguard Worker  return static_cast<directory_options>(~static_cast<unsigned char>(_LHS));
469*58b9f456SAndroid Build Coastguard Worker}
470*58b9f456SAndroid Build Coastguard Worker
471*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
472*58b9f456SAndroid Build Coastguard Workerinline directory_options& operator&=(directory_options& _LHS,
473*58b9f456SAndroid Build Coastguard Worker                                     directory_options _RHS) {
474*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS & _RHS;
475*58b9f456SAndroid Build Coastguard Worker}
476*58b9f456SAndroid Build Coastguard Worker
477*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
478*58b9f456SAndroid Build Coastguard Workerinline directory_options& operator|=(directory_options& _LHS,
479*58b9f456SAndroid Build Coastguard Worker                                     directory_options _RHS) {
480*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS | _RHS;
481*58b9f456SAndroid Build Coastguard Worker}
482*58b9f456SAndroid Build Coastguard Worker
483*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
484*58b9f456SAndroid Build Coastguard Workerinline directory_options& operator^=(directory_options& _LHS,
485*58b9f456SAndroid Build Coastguard Worker                                     directory_options _RHS) {
486*58b9f456SAndroid Build Coastguard Worker  return _LHS = _LHS ^ _RHS;
487*58b9f456SAndroid Build Coastguard Worker}
488*58b9f456SAndroid Build Coastguard Worker
489*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS file_status {
490*58b9f456SAndroid Build Coastguard Workerpublic:
491*58b9f456SAndroid Build Coastguard Worker  // constructors
492*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
493*58b9f456SAndroid Build Coastguard Worker  file_status() noexcept : file_status(file_type::none) {}
494*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
495*58b9f456SAndroid Build Coastguard Worker  explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept
496*58b9f456SAndroid Build Coastguard Worker      : __ft_(__ft),
497*58b9f456SAndroid Build Coastguard Worker        __prms_(__prms) {}
498*58b9f456SAndroid Build Coastguard Worker
499*58b9f456SAndroid Build Coastguard Worker  file_status(const file_status&) noexcept = default;
500*58b9f456SAndroid Build Coastguard Worker  file_status(file_status&&) noexcept = default;
501*58b9f456SAndroid Build Coastguard Worker
502*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
503*58b9f456SAndroid Build Coastguard Worker  ~file_status() {}
504*58b9f456SAndroid Build Coastguard Worker
505*58b9f456SAndroid Build Coastguard Worker  file_status& operator=(const file_status&) noexcept = default;
506*58b9f456SAndroid Build Coastguard Worker  file_status& operator=(file_status&&) noexcept = default;
507*58b9f456SAndroid Build Coastguard Worker
508*58b9f456SAndroid Build Coastguard Worker  // observers
509*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
510*58b9f456SAndroid Build Coastguard Worker  file_type type() const noexcept { return __ft_; }
511*58b9f456SAndroid Build Coastguard Worker
512*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
513*58b9f456SAndroid Build Coastguard Worker  perms permissions() const noexcept { return __prms_; }
514*58b9f456SAndroid Build Coastguard Worker
515*58b9f456SAndroid Build Coastguard Worker  // modifiers
516*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
517*58b9f456SAndroid Build Coastguard Worker  void type(file_type __ft) noexcept { __ft_ = __ft; }
518*58b9f456SAndroid Build Coastguard Worker
519*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
520*58b9f456SAndroid Build Coastguard Worker  void permissions(perms __p) noexcept { __prms_ = __p; }
521*58b9f456SAndroid Build Coastguard Worker
522*58b9f456SAndroid Build Coastguard Workerprivate:
523*58b9f456SAndroid Build Coastguard Worker  file_type __ft_;
524*58b9f456SAndroid Build Coastguard Worker  perms __prms_;
525*58b9f456SAndroid Build Coastguard Worker};
526*58b9f456SAndroid Build Coastguard Worker
527*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS directory_entry;
528*58b9f456SAndroid Build Coastguard Worker
529*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
530*58b9f456SAndroid Build Coastguard Workerstruct __can_convert_char {
531*58b9f456SAndroid Build Coastguard Worker  static const bool value = false;
532*58b9f456SAndroid Build Coastguard Worker};
533*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
534*58b9f456SAndroid Build Coastguard Workerstruct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {};
535*58b9f456SAndroid Build Coastguard Workertemplate <>
536*58b9f456SAndroid Build Coastguard Workerstruct __can_convert_char<char> {
537*58b9f456SAndroid Build Coastguard Worker  static const bool value = true;
538*58b9f456SAndroid Build Coastguard Worker  using __char_type = char;
539*58b9f456SAndroid Build Coastguard Worker};
540*58b9f456SAndroid Build Coastguard Workertemplate <>
541*58b9f456SAndroid Build Coastguard Workerstruct __can_convert_char<wchar_t> {
542*58b9f456SAndroid Build Coastguard Worker  static const bool value = true;
543*58b9f456SAndroid Build Coastguard Worker  using __char_type = wchar_t;
544*58b9f456SAndroid Build Coastguard Worker};
545*58b9f456SAndroid Build Coastguard Workertemplate <>
546*58b9f456SAndroid Build Coastguard Workerstruct __can_convert_char<char16_t> {
547*58b9f456SAndroid Build Coastguard Worker  static const bool value = true;
548*58b9f456SAndroid Build Coastguard Worker  using __char_type = char16_t;
549*58b9f456SAndroid Build Coastguard Worker};
550*58b9f456SAndroid Build Coastguard Workertemplate <>
551*58b9f456SAndroid Build Coastguard Workerstruct __can_convert_char<char32_t> {
552*58b9f456SAndroid Build Coastguard Worker  static const bool value = true;
553*58b9f456SAndroid Build Coastguard Worker  using __char_type = char32_t;
554*58b9f456SAndroid Build Coastguard Worker};
555*58b9f456SAndroid Build Coastguard Worker
556*58b9f456SAndroid Build Coastguard Workertemplate <class _ECharT>
557*58b9f456SAndroid Build Coastguard Workertypename enable_if<__can_convert_char<_ECharT>::value, bool>::type
558*58b9f456SAndroid Build Coastguard Worker__is_separator(_ECharT __e) {
559*58b9f456SAndroid Build Coastguard Worker  return __e == _ECharT('/');
560*58b9f456SAndroid Build Coastguard Worker}
561*58b9f456SAndroid Build Coastguard Worker
562*58b9f456SAndroid Build Coastguard Workerstruct _NullSentinal {};
563*58b9f456SAndroid Build Coastguard Worker
564*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
565*58b9f456SAndroid Build Coastguard Workerusing _Void = void;
566*58b9f456SAndroid Build Coastguard Worker
567*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class = void>
568*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_string : public false_type {};
569*58b9f456SAndroid Build Coastguard Worker
570*58b9f456SAndroid Build Coastguard Workertemplate <class _ECharT, class _Traits, class _Alloc>
571*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_string<
572*58b9f456SAndroid Build Coastguard Worker    basic_string<_ECharT, _Traits, _Alloc>,
573*58b9f456SAndroid Build Coastguard Worker    _Void<typename __can_convert_char<_ECharT>::__char_type> >
574*58b9f456SAndroid Build Coastguard Worker    : public __can_convert_char<_ECharT> {
575*58b9f456SAndroid Build Coastguard Worker  using _Str = basic_string<_ECharT, _Traits, _Alloc>;
576*58b9f456SAndroid Build Coastguard Worker  using _Base = __can_convert_char<_ECharT>;
577*58b9f456SAndroid Build Coastguard Worker  static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
578*58b9f456SAndroid Build Coastguard Worker  static _ECharT const* __range_end(_Str const& __s) {
579*58b9f456SAndroid Build Coastguard Worker    return __s.data() + __s.length();
580*58b9f456SAndroid Build Coastguard Worker  }
581*58b9f456SAndroid Build Coastguard Worker  static _ECharT __first_or_null(_Str const& __s) {
582*58b9f456SAndroid Build Coastguard Worker    return __s.empty() ? _ECharT{} : __s[0];
583*58b9f456SAndroid Build Coastguard Worker  }
584*58b9f456SAndroid Build Coastguard Worker};
585*58b9f456SAndroid Build Coastguard Worker
586*58b9f456SAndroid Build Coastguard Workertemplate <class _ECharT, class _Traits>
587*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_string<
588*58b9f456SAndroid Build Coastguard Worker    basic_string_view<_ECharT, _Traits>,
589*58b9f456SAndroid Build Coastguard Worker    _Void<typename __can_convert_char<_ECharT>::__char_type> >
590*58b9f456SAndroid Build Coastguard Worker    : public __can_convert_char<_ECharT> {
591*58b9f456SAndroid Build Coastguard Worker  using _Str = basic_string_view<_ECharT, _Traits>;
592*58b9f456SAndroid Build Coastguard Worker  using _Base = __can_convert_char<_ECharT>;
593*58b9f456SAndroid Build Coastguard Worker  static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
594*58b9f456SAndroid Build Coastguard Worker  static _ECharT const* __range_end(_Str const& __s) {
595*58b9f456SAndroid Build Coastguard Worker    return __s.data() + __s.length();
596*58b9f456SAndroid Build Coastguard Worker  }
597*58b9f456SAndroid Build Coastguard Worker  static _ECharT __first_or_null(_Str const& __s) {
598*58b9f456SAndroid Build Coastguard Worker    return __s.empty() ? _ECharT{} : __s[0];
599*58b9f456SAndroid Build Coastguard Worker  }
600*58b9f456SAndroid Build Coastguard Worker};
601*58b9f456SAndroid Build Coastguard Worker
602*58b9f456SAndroid Build Coastguard Workertemplate <class _Source, class _DS = typename decay<_Source>::type,
603*58b9f456SAndroid Build Coastguard Worker          class _UnqualPtrType =
604*58b9f456SAndroid Build Coastguard Worker              typename remove_const<typename remove_pointer<_DS>::type>::type,
605*58b9f456SAndroid Build Coastguard Worker          bool _IsCharPtr = is_pointer<_DS>::value&&
606*58b9f456SAndroid Build Coastguard Worker              __can_convert_char<_UnqualPtrType>::value>
607*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_char_array : false_type {};
608*58b9f456SAndroid Build Coastguard Worker
609*58b9f456SAndroid Build Coastguard Workertemplate <class _Source, class _ECharT, class _UPtr>
610*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
611*58b9f456SAndroid Build Coastguard Worker    : __can_convert_char<typename remove_const<_ECharT>::type> {
612*58b9f456SAndroid Build Coastguard Worker  using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
613*58b9f456SAndroid Build Coastguard Worker
614*58b9f456SAndroid Build Coastguard Worker  static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
615*58b9f456SAndroid Build Coastguard Worker  static _ECharT const* __range_end(const _ECharT* __b) {
616*58b9f456SAndroid Build Coastguard Worker    using _Iter = const _ECharT*;
617*58b9f456SAndroid Build Coastguard Worker    const _ECharT __sentinal = _ECharT{};
618*58b9f456SAndroid Build Coastguard Worker    _Iter __e = __b;
619*58b9f456SAndroid Build Coastguard Worker    for (; *__e != __sentinal; ++__e)
620*58b9f456SAndroid Build Coastguard Worker      ;
621*58b9f456SAndroid Build Coastguard Worker    return __e;
622*58b9f456SAndroid Build Coastguard Worker  }
623*58b9f456SAndroid Build Coastguard Worker
624*58b9f456SAndroid Build Coastguard Worker  static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
625*58b9f456SAndroid Build Coastguard Worker};
626*58b9f456SAndroid Build Coastguard Worker
627*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter, bool _IsIt = __is_input_iterator<_Iter>::value,
628*58b9f456SAndroid Build Coastguard Worker          class = void>
629*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_iter : false_type {};
630*58b9f456SAndroid Build Coastguard Worker
631*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
632*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable_iter<
633*58b9f456SAndroid Build Coastguard Worker    _Iter, true,
634*58b9f456SAndroid Build Coastguard Worker    _Void<typename __can_convert_char<
635*58b9f456SAndroid Build Coastguard Worker        typename iterator_traits<_Iter>::value_type>::__char_type> >
636*58b9f456SAndroid Build Coastguard Worker    : __can_convert_char<typename iterator_traits<_Iter>::value_type> {
637*58b9f456SAndroid Build Coastguard Worker  using _ECharT = typename iterator_traits<_Iter>::value_type;
638*58b9f456SAndroid Build Coastguard Worker  using _Base = __can_convert_char<_ECharT>;
639*58b9f456SAndroid Build Coastguard Worker
640*58b9f456SAndroid Build Coastguard Worker  static _Iter __range_begin(_Iter __b) { return __b; }
641*58b9f456SAndroid Build Coastguard Worker  static _NullSentinal __range_end(_Iter) { return _NullSentinal{}; }
642*58b9f456SAndroid Build Coastguard Worker
643*58b9f456SAndroid Build Coastguard Worker  static _ECharT __first_or_null(_Iter __b) { return *__b; }
644*58b9f456SAndroid Build Coastguard Worker};
645*58b9f456SAndroid Build Coastguard Worker
646*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::value,
647*58b9f456SAndroid Build Coastguard Worker          bool _IsCharIterT = __is_pathable_char_array<_Tp>::value,
648*58b9f456SAndroid Build Coastguard Worker          bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value>
649*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable : false_type {
650*58b9f456SAndroid Build Coastguard Worker  static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false");
651*58b9f456SAndroid Build Coastguard Worker};
652*58b9f456SAndroid Build Coastguard Worker
653*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
654*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {};
655*58b9f456SAndroid Build Coastguard Worker
656*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
657*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {
658*58b9f456SAndroid Build Coastguard Worker};
659*58b9f456SAndroid Build Coastguard Worker
660*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
661*58b9f456SAndroid Build Coastguard Workerstruct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
662*58b9f456SAndroid Build Coastguard Worker
663*58b9f456SAndroid Build Coastguard Workertemplate <class _ECharT>
664*58b9f456SAndroid Build Coastguard Workerstruct _PathCVT {
665*58b9f456SAndroid Build Coastguard Worker  static_assert(__can_convert_char<_ECharT>::value,
666*58b9f456SAndroid Build Coastguard Worker                "Char type not convertible");
667*58b9f456SAndroid Build Coastguard Worker
668*58b9f456SAndroid Build Coastguard Worker  typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower;
669*58b9f456SAndroid Build Coastguard Worker
670*58b9f456SAndroid Build Coastguard Worker  static void __append_range(string& __dest, _ECharT const* __b,
671*58b9f456SAndroid Build Coastguard Worker                             _ECharT const* __e) {
672*58b9f456SAndroid Build Coastguard Worker    _Narrower()(back_inserter(__dest), __b, __e);
673*58b9f456SAndroid Build Coastguard Worker  }
674*58b9f456SAndroid Build Coastguard Worker
675*58b9f456SAndroid Build Coastguard Worker  template <class _Iter>
676*58b9f456SAndroid Build Coastguard Worker  static void __append_range(string& __dest, _Iter __b, _Iter __e) {
677*58b9f456SAndroid Build Coastguard Worker    static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
678*58b9f456SAndroid Build Coastguard Worker    if (__b == __e)
679*58b9f456SAndroid Build Coastguard Worker      return;
680*58b9f456SAndroid Build Coastguard Worker    basic_string<_ECharT> __tmp(__b, __e);
681*58b9f456SAndroid Build Coastguard Worker    _Narrower()(back_inserter(__dest), __tmp.data(),
682*58b9f456SAndroid Build Coastguard Worker                __tmp.data() + __tmp.length());
683*58b9f456SAndroid Build Coastguard Worker  }
684*58b9f456SAndroid Build Coastguard Worker
685*58b9f456SAndroid Build Coastguard Worker  template <class _Iter>
686*58b9f456SAndroid Build Coastguard Worker  static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
687*58b9f456SAndroid Build Coastguard Worker    static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
688*58b9f456SAndroid Build Coastguard Worker    const _ECharT __sentinal = _ECharT{};
689*58b9f456SAndroid Build Coastguard Worker    if (*__b == __sentinal)
690*58b9f456SAndroid Build Coastguard Worker      return;
691*58b9f456SAndroid Build Coastguard Worker    basic_string<_ECharT> __tmp;
692*58b9f456SAndroid Build Coastguard Worker    for (; *__b != __sentinal; ++__b)
693*58b9f456SAndroid Build Coastguard Worker      __tmp.push_back(*__b);
694*58b9f456SAndroid Build Coastguard Worker    _Narrower()(back_inserter(__dest), __tmp.data(),
695*58b9f456SAndroid Build Coastguard Worker                __tmp.data() + __tmp.length());
696*58b9f456SAndroid Build Coastguard Worker  }
697*58b9f456SAndroid Build Coastguard Worker
698*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
699*58b9f456SAndroid Build Coastguard Worker  static void __append_source(string& __dest, _Source const& __s) {
700*58b9f456SAndroid Build Coastguard Worker    using _Traits = __is_pathable<_Source>;
701*58b9f456SAndroid Build Coastguard Worker    __append_range(__dest, _Traits::__range_begin(__s),
702*58b9f456SAndroid Build Coastguard Worker                   _Traits::__range_end(__s));
703*58b9f456SAndroid Build Coastguard Worker  }
704*58b9f456SAndroid Build Coastguard Worker};
705*58b9f456SAndroid Build Coastguard Worker
706*58b9f456SAndroid Build Coastguard Workertemplate <>
707*58b9f456SAndroid Build Coastguard Workerstruct _PathCVT<char> {
708*58b9f456SAndroid Build Coastguard Worker
709*58b9f456SAndroid Build Coastguard Worker  template <class _Iter>
710*58b9f456SAndroid Build Coastguard Worker  static typename enable_if<__is_exactly_input_iterator<_Iter>::value>::type
711*58b9f456SAndroid Build Coastguard Worker  __append_range(string& __dest, _Iter __b, _Iter __e) {
712*58b9f456SAndroid Build Coastguard Worker    for (; __b != __e; ++__b)
713*58b9f456SAndroid Build Coastguard Worker      __dest.push_back(*__b);
714*58b9f456SAndroid Build Coastguard Worker  }
715*58b9f456SAndroid Build Coastguard Worker
716*58b9f456SAndroid Build Coastguard Worker  template <class _Iter>
717*58b9f456SAndroid Build Coastguard Worker  static typename enable_if<__is_forward_iterator<_Iter>::value>::type
718*58b9f456SAndroid Build Coastguard Worker  __append_range(string& __dest, _Iter __b, _Iter __e) {
719*58b9f456SAndroid Build Coastguard Worker    __dest.__append_forward_unsafe(__b, __e);
720*58b9f456SAndroid Build Coastguard Worker  }
721*58b9f456SAndroid Build Coastguard Worker
722*58b9f456SAndroid Build Coastguard Worker  template <class _Iter>
723*58b9f456SAndroid Build Coastguard Worker  static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
724*58b9f456SAndroid Build Coastguard Worker    const char __sentinal = char{};
725*58b9f456SAndroid Build Coastguard Worker    for (; *__b != __sentinal; ++__b)
726*58b9f456SAndroid Build Coastguard Worker      __dest.push_back(*__b);
727*58b9f456SAndroid Build Coastguard Worker  }
728*58b9f456SAndroid Build Coastguard Worker
729*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
730*58b9f456SAndroid Build Coastguard Worker  static void __append_source(string& __dest, _Source const& __s) {
731*58b9f456SAndroid Build Coastguard Worker    using _Traits = __is_pathable<_Source>;
732*58b9f456SAndroid Build Coastguard Worker    __append_range(__dest, _Traits::__range_begin(__s),
733*58b9f456SAndroid Build Coastguard Worker                   _Traits::__range_end(__s));
734*58b9f456SAndroid Build Coastguard Worker  }
735*58b9f456SAndroid Build Coastguard Worker};
736*58b9f456SAndroid Build Coastguard Worker
737*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS path {
738*58b9f456SAndroid Build Coastguard Worker  template <class _SourceOrIter, class _Tp = path&>
739*58b9f456SAndroid Build Coastguard Worker  using _EnableIfPathable =
740*58b9f456SAndroid Build Coastguard Worker      typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type;
741*58b9f456SAndroid Build Coastguard Worker
742*58b9f456SAndroid Build Coastguard Worker  template <class _Tp>
743*58b9f456SAndroid Build Coastguard Worker  using _SourceChar = typename __is_pathable<_Tp>::__char_type;
744*58b9f456SAndroid Build Coastguard Worker
745*58b9f456SAndroid Build Coastguard Worker  template <class _Tp>
746*58b9f456SAndroid Build Coastguard Worker  using _SourceCVT = _PathCVT<_SourceChar<_Tp> >;
747*58b9f456SAndroid Build Coastguard Worker
748*58b9f456SAndroid Build Coastguard Workerpublic:
749*58b9f456SAndroid Build Coastguard Worker  typedef char value_type;
750*58b9f456SAndroid Build Coastguard Worker  typedef basic_string<value_type> string_type;
751*58b9f456SAndroid Build Coastguard Worker  typedef _VSTD::string_view __string_view;
752*58b9f456SAndroid Build Coastguard Worker  static constexpr value_type preferred_separator = '/';
753*58b9f456SAndroid Build Coastguard Worker
754*58b9f456SAndroid Build Coastguard Worker  enum class _LIBCPP_ENUM_VIS format : unsigned char {
755*58b9f456SAndroid Build Coastguard Worker    auto_format,
756*58b9f456SAndroid Build Coastguard Worker    native_format,
757*58b9f456SAndroid Build Coastguard Worker    generic_format
758*58b9f456SAndroid Build Coastguard Worker  };
759*58b9f456SAndroid Build Coastguard Worker
760*58b9f456SAndroid Build Coastguard Worker  // constructors and destructor
761*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path() noexcept {}
762*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {}
763*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept
764*58b9f456SAndroid Build Coastguard Worker      : __pn_(_VSTD::move(__p.__pn_)) {}
765*58b9f456SAndroid Build Coastguard Worker
766*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
767*58b9f456SAndroid Build Coastguard Worker  path(string_type&& __s, format = format::auto_format) noexcept
768*58b9f456SAndroid Build Coastguard Worker      : __pn_(_VSTD::move(__s)) {}
769*58b9f456SAndroid Build Coastguard Worker
770*58b9f456SAndroid Build Coastguard Worker  template <class _Source, class = _EnableIfPathable<_Source, void> >
771*58b9f456SAndroid Build Coastguard Worker  path(const _Source& __src, format = format::auto_format) {
772*58b9f456SAndroid Build Coastguard Worker    _SourceCVT<_Source>::__append_source(__pn_, __src);
773*58b9f456SAndroid Build Coastguard Worker  }
774*58b9f456SAndroid Build Coastguard Worker
775*58b9f456SAndroid Build Coastguard Worker  template <class _InputIt>
776*58b9f456SAndroid Build Coastguard Worker  path(_InputIt __first, _InputIt __last, format = format::auto_format) {
777*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
778*58b9f456SAndroid Build Coastguard Worker    _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
779*58b9f456SAndroid Build Coastguard Worker  }
780*58b9f456SAndroid Build Coastguard Worker
781*58b9f456SAndroid Build Coastguard Worker  // TODO Implement locale conversions.
782*58b9f456SAndroid Build Coastguard Worker  template <class _Source, class = _EnableIfPathable<_Source, void> >
783*58b9f456SAndroid Build Coastguard Worker  path(const _Source& __src, const locale& __loc, format = format::auto_format);
784*58b9f456SAndroid Build Coastguard Worker  template <class _InputIt>
785*58b9f456SAndroid Build Coastguard Worker  path(_InputIt __first, _InputIt _last, const locale& __loc,
786*58b9f456SAndroid Build Coastguard Worker       format = format::auto_format);
787*58b9f456SAndroid Build Coastguard Worker
788*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
789*58b9f456SAndroid Build Coastguard Worker  ~path() = default;
790*58b9f456SAndroid Build Coastguard Worker
791*58b9f456SAndroid Build Coastguard Worker  // assignments
792*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
793*58b9f456SAndroid Build Coastguard Worker  path& operator=(const path& __p) {
794*58b9f456SAndroid Build Coastguard Worker    __pn_ = __p.__pn_;
795*58b9f456SAndroid Build Coastguard Worker    return *this;
796*58b9f456SAndroid Build Coastguard Worker  }
797*58b9f456SAndroid Build Coastguard Worker
798*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
799*58b9f456SAndroid Build Coastguard Worker  path& operator=(path&& __p) noexcept {
800*58b9f456SAndroid Build Coastguard Worker    __pn_ = _VSTD::move(__p.__pn_);
801*58b9f456SAndroid Build Coastguard Worker    return *this;
802*58b9f456SAndroid Build Coastguard Worker  }
803*58b9f456SAndroid Build Coastguard Worker
804*58b9f456SAndroid Build Coastguard Worker  template <class = void>
805*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path& operator=(string_type&& __s) noexcept {
806*58b9f456SAndroid Build Coastguard Worker    __pn_ = _VSTD::move(__s);
807*58b9f456SAndroid Build Coastguard Worker    return *this;
808*58b9f456SAndroid Build Coastguard Worker  }
809*58b9f456SAndroid Build Coastguard Worker
810*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
811*58b9f456SAndroid Build Coastguard Worker  path& assign(string_type&& __s) noexcept {
812*58b9f456SAndroid Build Coastguard Worker    __pn_ = _VSTD::move(__s);
813*58b9f456SAndroid Build Coastguard Worker    return *this;
814*58b9f456SAndroid Build Coastguard Worker  }
815*58b9f456SAndroid Build Coastguard Worker
816*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
817*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
818*58b9f456SAndroid Build Coastguard Worker  operator=(const _Source& __src) {
819*58b9f456SAndroid Build Coastguard Worker    return this->assign(__src);
820*58b9f456SAndroid Build Coastguard Worker  }
821*58b9f456SAndroid Build Coastguard Worker
822*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
823*58b9f456SAndroid Build Coastguard Worker  _EnableIfPathable<_Source> assign(const _Source& __src) {
824*58b9f456SAndroid Build Coastguard Worker    __pn_.clear();
825*58b9f456SAndroid Build Coastguard Worker    _SourceCVT<_Source>::__append_source(__pn_, __src);
826*58b9f456SAndroid Build Coastguard Worker    return *this;
827*58b9f456SAndroid Build Coastguard Worker  }
828*58b9f456SAndroid Build Coastguard Worker
829*58b9f456SAndroid Build Coastguard Worker  template <class _InputIt>
830*58b9f456SAndroid Build Coastguard Worker  path& assign(_InputIt __first, _InputIt __last) {
831*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
832*58b9f456SAndroid Build Coastguard Worker    __pn_.clear();
833*58b9f456SAndroid Build Coastguard Worker    _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
834*58b9f456SAndroid Build Coastguard Worker    return *this;
835*58b9f456SAndroid Build Coastguard Worker  }
836*58b9f456SAndroid Build Coastguard Worker
837*58b9f456SAndroid Build Coastguard Workerprivate:
838*58b9f456SAndroid Build Coastguard Worker  template <class _ECharT>
839*58b9f456SAndroid Build Coastguard Worker  static bool __source_is_absolute(_ECharT __first_or_null) {
840*58b9f456SAndroid Build Coastguard Worker    return __is_separator(__first_or_null);
841*58b9f456SAndroid Build Coastguard Worker  }
842*58b9f456SAndroid Build Coastguard Worker
843*58b9f456SAndroid Build Coastguard Workerpublic:
844*58b9f456SAndroid Build Coastguard Worker  // appends
845*58b9f456SAndroid Build Coastguard Worker  path& operator/=(const path& __p) {
846*58b9f456SAndroid Build Coastguard Worker    if (__p.is_absolute()) {
847*58b9f456SAndroid Build Coastguard Worker      __pn_ = __p.__pn_;
848*58b9f456SAndroid Build Coastguard Worker      return *this;
849*58b9f456SAndroid Build Coastguard Worker    }
850*58b9f456SAndroid Build Coastguard Worker    if (has_filename())
851*58b9f456SAndroid Build Coastguard Worker      __pn_ += preferred_separator;
852*58b9f456SAndroid Build Coastguard Worker    __pn_ += __p.native();
853*58b9f456SAndroid Build Coastguard Worker    return *this;
854*58b9f456SAndroid Build Coastguard Worker  }
855*58b9f456SAndroid Build Coastguard Worker
856*58b9f456SAndroid Build Coastguard Worker  // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src
857*58b9f456SAndroid Build Coastguard Worker  // is known at compile time to be "/' since the user almost certainly intended
858*58b9f456SAndroid Build Coastguard Worker  // to append a separator instead of overwriting the path with "/"
859*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
860*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
861*58b9f456SAndroid Build Coastguard Worker  operator/=(const _Source& __src) {
862*58b9f456SAndroid Build Coastguard Worker    return this->append(__src);
863*58b9f456SAndroid Build Coastguard Worker  }
864*58b9f456SAndroid Build Coastguard Worker
865*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
866*58b9f456SAndroid Build Coastguard Worker  _EnableIfPathable<_Source> append(const _Source& __src) {
867*58b9f456SAndroid Build Coastguard Worker    using _Traits = __is_pathable<_Source>;
868*58b9f456SAndroid Build Coastguard Worker    using _CVT = _PathCVT<_SourceChar<_Source> >;
869*58b9f456SAndroid Build Coastguard Worker    if (__source_is_absolute(_Traits::__first_or_null(__src)))
870*58b9f456SAndroid Build Coastguard Worker      __pn_.clear();
871*58b9f456SAndroid Build Coastguard Worker    else if (has_filename())
872*58b9f456SAndroid Build Coastguard Worker      __pn_ += preferred_separator;
873*58b9f456SAndroid Build Coastguard Worker    _CVT::__append_source(__pn_, __src);
874*58b9f456SAndroid Build Coastguard Worker    return *this;
875*58b9f456SAndroid Build Coastguard Worker  }
876*58b9f456SAndroid Build Coastguard Worker
877*58b9f456SAndroid Build Coastguard Worker  template <class _InputIt>
878*58b9f456SAndroid Build Coastguard Worker  path& append(_InputIt __first, _InputIt __last) {
879*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
880*58b9f456SAndroid Build Coastguard Worker    static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
881*58b9f456SAndroid Build Coastguard Worker    using _CVT = _PathCVT<_ItVal>;
882*58b9f456SAndroid Build Coastguard Worker    if (__first != __last && __source_is_absolute(*__first))
883*58b9f456SAndroid Build Coastguard Worker      __pn_.clear();
884*58b9f456SAndroid Build Coastguard Worker    else if (has_filename())
885*58b9f456SAndroid Build Coastguard Worker      __pn_ += preferred_separator;
886*58b9f456SAndroid Build Coastguard Worker    _CVT::__append_range(__pn_, __first, __last);
887*58b9f456SAndroid Build Coastguard Worker    return *this;
888*58b9f456SAndroid Build Coastguard Worker  }
889*58b9f456SAndroid Build Coastguard Worker
890*58b9f456SAndroid Build Coastguard Worker  // concatenation
891*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
892*58b9f456SAndroid Build Coastguard Worker  path& operator+=(const path& __x) {
893*58b9f456SAndroid Build Coastguard Worker    __pn_ += __x.__pn_;
894*58b9f456SAndroid Build Coastguard Worker    return *this;
895*58b9f456SAndroid Build Coastguard Worker  }
896*58b9f456SAndroid Build Coastguard Worker
897*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
898*58b9f456SAndroid Build Coastguard Worker  path& operator+=(const string_type& __x) {
899*58b9f456SAndroid Build Coastguard Worker    __pn_ += __x;
900*58b9f456SAndroid Build Coastguard Worker    return *this;
901*58b9f456SAndroid Build Coastguard Worker  }
902*58b9f456SAndroid Build Coastguard Worker
903*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
904*58b9f456SAndroid Build Coastguard Worker  path& operator+=(__string_view __x) {
905*58b9f456SAndroid Build Coastguard Worker    __pn_ += __x;
906*58b9f456SAndroid Build Coastguard Worker    return *this;
907*58b9f456SAndroid Build Coastguard Worker  }
908*58b9f456SAndroid Build Coastguard Worker
909*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
910*58b9f456SAndroid Build Coastguard Worker  path& operator+=(const value_type* __x) {
911*58b9f456SAndroid Build Coastguard Worker    __pn_ += __x;
912*58b9f456SAndroid Build Coastguard Worker    return *this;
913*58b9f456SAndroid Build Coastguard Worker  }
914*58b9f456SAndroid Build Coastguard Worker
915*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
916*58b9f456SAndroid Build Coastguard Worker  path& operator+=(value_type __x) {
917*58b9f456SAndroid Build Coastguard Worker    __pn_ += __x;
918*58b9f456SAndroid Build Coastguard Worker    return *this;
919*58b9f456SAndroid Build Coastguard Worker  }
920*58b9f456SAndroid Build Coastguard Worker
921*58b9f456SAndroid Build Coastguard Worker  template <class _ECharT>
922*58b9f456SAndroid Build Coastguard Worker  typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
923*58b9f456SAndroid Build Coastguard Worker  operator+=(_ECharT __x) {
924*58b9f456SAndroid Build Coastguard Worker    basic_string<_ECharT> __tmp;
925*58b9f456SAndroid Build Coastguard Worker    __tmp += __x;
926*58b9f456SAndroid Build Coastguard Worker    _PathCVT<_ECharT>::__append_source(__pn_, __tmp);
927*58b9f456SAndroid Build Coastguard Worker    return *this;
928*58b9f456SAndroid Build Coastguard Worker  }
929*58b9f456SAndroid Build Coastguard Worker
930*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
931*58b9f456SAndroid Build Coastguard Worker  _EnableIfPathable<_Source> operator+=(const _Source& __x) {
932*58b9f456SAndroid Build Coastguard Worker    return this->concat(__x);
933*58b9f456SAndroid Build Coastguard Worker  }
934*58b9f456SAndroid Build Coastguard Worker
935*58b9f456SAndroid Build Coastguard Worker  template <class _Source>
936*58b9f456SAndroid Build Coastguard Worker  _EnableIfPathable<_Source> concat(const _Source& __x) {
937*58b9f456SAndroid Build Coastguard Worker    _SourceCVT<_Source>::__append_source(__pn_, __x);
938*58b9f456SAndroid Build Coastguard Worker    return *this;
939*58b9f456SAndroid Build Coastguard Worker  }
940*58b9f456SAndroid Build Coastguard Worker
941*58b9f456SAndroid Build Coastguard Worker  template <class _InputIt>
942*58b9f456SAndroid Build Coastguard Worker  path& concat(_InputIt __first, _InputIt __last) {
943*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_InputIt>::value_type _ItVal;
944*58b9f456SAndroid Build Coastguard Worker    _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
945*58b9f456SAndroid Build Coastguard Worker    return *this;
946*58b9f456SAndroid Build Coastguard Worker  }
947*58b9f456SAndroid Build Coastguard Worker
948*58b9f456SAndroid Build Coastguard Worker  // modifiers
949*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
950*58b9f456SAndroid Build Coastguard Worker  void clear() noexcept { __pn_.clear(); }
951*58b9f456SAndroid Build Coastguard Worker
952*58b9f456SAndroid Build Coastguard Worker  path& make_preferred() { return *this; }
953*58b9f456SAndroid Build Coastguard Worker
954*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
955*58b9f456SAndroid Build Coastguard Worker  path& remove_filename() {
956*58b9f456SAndroid Build Coastguard Worker    auto __fname = __filename();
957*58b9f456SAndroid Build Coastguard Worker    if (!__fname.empty())
958*58b9f456SAndroid Build Coastguard Worker      __pn_.erase(__fname.data() - __pn_.data());
959*58b9f456SAndroid Build Coastguard Worker    return *this;
960*58b9f456SAndroid Build Coastguard Worker  }
961*58b9f456SAndroid Build Coastguard Worker
962*58b9f456SAndroid Build Coastguard Worker  path& replace_filename(const path& __replacement) {
963*58b9f456SAndroid Build Coastguard Worker    remove_filename();
964*58b9f456SAndroid Build Coastguard Worker    return (*this /= __replacement);
965*58b9f456SAndroid Build Coastguard Worker  }
966*58b9f456SAndroid Build Coastguard Worker
967*58b9f456SAndroid Build Coastguard Worker  path& replace_extension(const path& __replacement = path());
968*58b9f456SAndroid Build Coastguard Worker
969*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
970*58b9f456SAndroid Build Coastguard Worker  void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
971*58b9f456SAndroid Build Coastguard Worker
972*58b9f456SAndroid Build Coastguard Worker  // private helper to allow reserving memory in the path
973*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
974*58b9f456SAndroid Build Coastguard Worker  void __reserve(size_t __s) { __pn_.reserve(__s); }
975*58b9f456SAndroid Build Coastguard Worker
976*58b9f456SAndroid Build Coastguard Worker  // native format observers
977*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
978*58b9f456SAndroid Build Coastguard Worker  const string_type& native() const noexcept { return __pn_; }
979*58b9f456SAndroid Build Coastguard Worker
980*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
981*58b9f456SAndroid Build Coastguard Worker  const value_type* c_str() const noexcept { return __pn_.c_str(); }
982*58b9f456SAndroid Build Coastguard Worker
983*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }
984*58b9f456SAndroid Build Coastguard Worker
985*58b9f456SAndroid Build Coastguard Worker  template <class _ECharT, class _Traits = char_traits<_ECharT>,
986*58b9f456SAndroid Build Coastguard Worker            class _Allocator = allocator<_ECharT> >
987*58b9f456SAndroid Build Coastguard Worker  basic_string<_ECharT, _Traits, _Allocator>
988*58b9f456SAndroid Build Coastguard Worker  string(const _Allocator& __a = _Allocator()) const {
989*58b9f456SAndroid Build Coastguard Worker    using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
990*58b9f456SAndroid Build Coastguard Worker    using _Str = basic_string<_ECharT, _Traits, _Allocator>;
991*58b9f456SAndroid Build Coastguard Worker    _Str __s(__a);
992*58b9f456SAndroid Build Coastguard Worker    __s.reserve(__pn_.size());
993*58b9f456SAndroid Build Coastguard Worker    _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
994*58b9f456SAndroid Build Coastguard Worker    return __s;
995*58b9f456SAndroid Build Coastguard Worker  }
996*58b9f456SAndroid Build Coastguard Worker
997*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }
998*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY std::wstring wstring() const {
999*58b9f456SAndroid Build Coastguard Worker    return string<wchar_t>();
1000*58b9f456SAndroid Build Coastguard Worker  }
1001*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; }
1002*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const {
1003*58b9f456SAndroid Build Coastguard Worker    return string<char16_t>();
1004*58b9f456SAndroid Build Coastguard Worker  }
1005*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const {
1006*58b9f456SAndroid Build Coastguard Worker    return string<char32_t>();
1007*58b9f456SAndroid Build Coastguard Worker  }
1008*58b9f456SAndroid Build Coastguard Worker
1009*58b9f456SAndroid Build Coastguard Worker  // generic format observers
1010*58b9f456SAndroid Build Coastguard Worker  template <class _ECharT, class _Traits = char_traits<_ECharT>,
1011*58b9f456SAndroid Build Coastguard Worker            class _Allocator = allocator<_ECharT> >
1012*58b9f456SAndroid Build Coastguard Worker  basic_string<_ECharT, _Traits, _Allocator>
1013*58b9f456SAndroid Build Coastguard Worker  generic_string(const _Allocator& __a = _Allocator()) const {
1014*58b9f456SAndroid Build Coastguard Worker    return string<_ECharT, _Traits, _Allocator>(__a);
1015*58b9f456SAndroid Build Coastguard Worker  }
1016*58b9f456SAndroid Build Coastguard Worker
1017*58b9f456SAndroid Build Coastguard Worker  std::string generic_string() const { return __pn_; }
1018*58b9f456SAndroid Build Coastguard Worker  std::wstring generic_wstring() const { return string<wchar_t>(); }
1019*58b9f456SAndroid Build Coastguard Worker  std::string generic_u8string() const { return __pn_; }
1020*58b9f456SAndroid Build Coastguard Worker  std::u16string generic_u16string() const { return string<char16_t>(); }
1021*58b9f456SAndroid Build Coastguard Worker  std::u32string generic_u32string() const { return string<char32_t>(); }
1022*58b9f456SAndroid Build Coastguard Worker
1023*58b9f456SAndroid Build Coastguard Workerprivate:
1024*58b9f456SAndroid Build Coastguard Worker  int __compare(__string_view) const;
1025*58b9f456SAndroid Build Coastguard Worker  __string_view __root_name() const;
1026*58b9f456SAndroid Build Coastguard Worker  __string_view __root_directory() const;
1027*58b9f456SAndroid Build Coastguard Worker  __string_view __root_path_raw() const;
1028*58b9f456SAndroid Build Coastguard Worker  __string_view __relative_path() const;
1029*58b9f456SAndroid Build Coastguard Worker  __string_view __parent_path() const;
1030*58b9f456SAndroid Build Coastguard Worker  __string_view __filename() const;
1031*58b9f456SAndroid Build Coastguard Worker  __string_view __stem() const;
1032*58b9f456SAndroid Build Coastguard Worker  __string_view __extension() const;
1033*58b9f456SAndroid Build Coastguard Worker
1034*58b9f456SAndroid Build Coastguard Workerpublic:
1035*58b9f456SAndroid Build Coastguard Worker  // compare
1036*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept {
1037*58b9f456SAndroid Build Coastguard Worker    return __compare(__p.__pn_);
1038*58b9f456SAndroid Build Coastguard Worker  }
1039*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const {
1040*58b9f456SAndroid Build Coastguard Worker    return __compare(__s);
1041*58b9f456SAndroid Build Coastguard Worker  }
1042*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const {
1043*58b9f456SAndroid Build Coastguard Worker    return __compare(__s);
1044*58b9f456SAndroid Build Coastguard Worker  }
1045*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const {
1046*58b9f456SAndroid Build Coastguard Worker    return __compare(__s);
1047*58b9f456SAndroid Build Coastguard Worker  }
1048*58b9f456SAndroid Build Coastguard Worker
1049*58b9f456SAndroid Build Coastguard Worker  // decomposition
1050*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path root_name() const {
1051*58b9f456SAndroid Build Coastguard Worker    return string_type(__root_name());
1052*58b9f456SAndroid Build Coastguard Worker  }
1053*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path root_directory() const {
1054*58b9f456SAndroid Build Coastguard Worker    return string_type(__root_directory());
1055*58b9f456SAndroid Build Coastguard Worker  }
1056*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path root_path() const {
1057*58b9f456SAndroid Build Coastguard Worker    return root_name().append(string_type(__root_directory()));
1058*58b9f456SAndroid Build Coastguard Worker  }
1059*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path relative_path() const {
1060*58b9f456SAndroid Build Coastguard Worker    return string_type(__relative_path());
1061*58b9f456SAndroid Build Coastguard Worker  }
1062*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path parent_path() const {
1063*58b9f456SAndroid Build Coastguard Worker    return string_type(__parent_path());
1064*58b9f456SAndroid Build Coastguard Worker  }
1065*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path filename() const {
1066*58b9f456SAndroid Build Coastguard Worker    return string_type(__filename());
1067*58b9f456SAndroid Build Coastguard Worker  }
1068*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); }
1069*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path extension() const {
1070*58b9f456SAndroid Build Coastguard Worker    return string_type(__extension());
1071*58b9f456SAndroid Build Coastguard Worker  }
1072*58b9f456SAndroid Build Coastguard Worker
1073*58b9f456SAndroid Build Coastguard Worker  // query
1074*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool
1075*58b9f456SAndroid Build Coastguard Worker  empty() const noexcept {
1076*58b9f456SAndroid Build Coastguard Worker    return __pn_.empty();
1077*58b9f456SAndroid Build Coastguard Worker  }
1078*58b9f456SAndroid Build Coastguard Worker
1079*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_root_name() const {
1080*58b9f456SAndroid Build Coastguard Worker    return !__root_name().empty();
1081*58b9f456SAndroid Build Coastguard Worker  }
1082*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const {
1083*58b9f456SAndroid Build Coastguard Worker    return !__root_directory().empty();
1084*58b9f456SAndroid Build Coastguard Worker  }
1085*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_root_path() const {
1086*58b9f456SAndroid Build Coastguard Worker    return !__root_path_raw().empty();
1087*58b9f456SAndroid Build Coastguard Worker  }
1088*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const {
1089*58b9f456SAndroid Build Coastguard Worker    return !__relative_path().empty();
1090*58b9f456SAndroid Build Coastguard Worker  }
1091*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const {
1092*58b9f456SAndroid Build Coastguard Worker    return !__parent_path().empty();
1093*58b9f456SAndroid Build Coastguard Worker  }
1094*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_filename() const {
1095*58b9f456SAndroid Build Coastguard Worker    return !__filename().empty();
1096*58b9f456SAndroid Build Coastguard Worker  }
1097*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); }
1098*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool has_extension() const {
1099*58b9f456SAndroid Build Coastguard Worker    return !__extension().empty();
1100*58b9f456SAndroid Build Coastguard Worker  }
1101*58b9f456SAndroid Build Coastguard Worker
1102*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool is_absolute() const {
1103*58b9f456SAndroid Build Coastguard Worker    return has_root_directory();
1104*58b9f456SAndroid Build Coastguard Worker  }
1105*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); }
1106*58b9f456SAndroid Build Coastguard Worker
1107*58b9f456SAndroid Build Coastguard Worker  // relative paths
1108*58b9f456SAndroid Build Coastguard Worker  path lexically_normal() const;
1109*58b9f456SAndroid Build Coastguard Worker  path lexically_relative(const path& __base) const;
1110*58b9f456SAndroid Build Coastguard Worker
1111*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const {
1112*58b9f456SAndroid Build Coastguard Worker    path __result = this->lexically_relative(__base);
1113*58b9f456SAndroid Build Coastguard Worker    if (__result.native().empty())
1114*58b9f456SAndroid Build Coastguard Worker      return *this;
1115*58b9f456SAndroid Build Coastguard Worker    return __result;
1116*58b9f456SAndroid Build Coastguard Worker  }
1117*58b9f456SAndroid Build Coastguard Worker
1118*58b9f456SAndroid Build Coastguard Worker  // iterators
1119*58b9f456SAndroid Build Coastguard Worker  class _LIBCPP_TYPE_VIS iterator;
1120*58b9f456SAndroid Build Coastguard Worker  typedef iterator const_iterator;
1121*58b9f456SAndroid Build Coastguard Worker
1122*58b9f456SAndroid Build Coastguard Worker  iterator begin() const;
1123*58b9f456SAndroid Build Coastguard Worker  iterator end() const;
1124*58b9f456SAndroid Build Coastguard Worker
1125*58b9f456SAndroid Build Coastguard Worker  template <class _CharT, class _Traits>
1126*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend
1127*58b9f456SAndroid Build Coastguard Worker      typename enable_if<is_same<_CharT, char>::value &&
1128*58b9f456SAndroid Build Coastguard Worker                             is_same<_Traits, char_traits<char> >::value,
1129*58b9f456SAndroid Build Coastguard Worker                         basic_ostream<_CharT, _Traits>&>::type
1130*58b9f456SAndroid Build Coastguard Worker      operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
1131*58b9f456SAndroid Build Coastguard Worker    __os << std::__quoted(__p.native());
1132*58b9f456SAndroid Build Coastguard Worker    return __os;
1133*58b9f456SAndroid Build Coastguard Worker  }
1134*58b9f456SAndroid Build Coastguard Worker
1135*58b9f456SAndroid Build Coastguard Worker  template <class _CharT, class _Traits>
1136*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend
1137*58b9f456SAndroid Build Coastguard Worker      typename enable_if<!is_same<_CharT, char>::value ||
1138*58b9f456SAndroid Build Coastguard Worker                             !is_same<_Traits, char_traits<char> >::value,
1139*58b9f456SAndroid Build Coastguard Worker                         basic_ostream<_CharT, _Traits>&>::type
1140*58b9f456SAndroid Build Coastguard Worker      operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
1141*58b9f456SAndroid Build Coastguard Worker    __os << std::__quoted(__p.string<_CharT, _Traits>());
1142*58b9f456SAndroid Build Coastguard Worker    return __os;
1143*58b9f456SAndroid Build Coastguard Worker  }
1144*58b9f456SAndroid Build Coastguard Worker
1145*58b9f456SAndroid Build Coastguard Worker  template <class _CharT, class _Traits>
1146*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>&
1147*58b9f456SAndroid Build Coastguard Worker  operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
1148*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits> __tmp;
1149*58b9f456SAndroid Build Coastguard Worker    __is >> __quoted(__tmp);
1150*58b9f456SAndroid Build Coastguard Worker    __p = __tmp;
1151*58b9f456SAndroid Build Coastguard Worker    return __is;
1152*58b9f456SAndroid Build Coastguard Worker  }
1153*58b9f456SAndroid Build Coastguard Worker
1154*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
1155*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) == 0;
1156*58b9f456SAndroid Build Coastguard Worker  }
1157*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {
1158*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) != 0;
1159*58b9f456SAndroid Build Coastguard Worker  }
1160*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {
1161*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) < 0;
1162*58b9f456SAndroid Build Coastguard Worker  }
1163*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {
1164*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) <= 0;
1165*58b9f456SAndroid Build Coastguard Worker  }
1166*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {
1167*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) > 0;
1168*58b9f456SAndroid Build Coastguard Worker  }
1169*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {
1170*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) >= 0;
1171*58b9f456SAndroid Build Coastguard Worker  }
1172*58b9f456SAndroid Build Coastguard Worker
1173*58b9f456SAndroid Build Coastguard Worker  friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
1174*58b9f456SAndroid Build Coastguard Worker                                                  const path& __rhs) {
1175*58b9f456SAndroid Build Coastguard Worker    path __result(__lhs);
1176*58b9f456SAndroid Build Coastguard Worker    __result /= __rhs;
1177*58b9f456SAndroid Build Coastguard Worker    return __result;
1178*58b9f456SAndroid Build Coastguard Worker  }
1179*58b9f456SAndroid Build Coastguard Workerprivate:
1180*58b9f456SAndroid Build Coastguard Worker  inline _LIBCPP_INLINE_VISIBILITY path&
1181*58b9f456SAndroid Build Coastguard Worker  __assign_view(__string_view const& __s) noexcept {
1182*58b9f456SAndroid Build Coastguard Worker    __pn_ = string_type(__s);
1183*58b9f456SAndroid Build Coastguard Worker    return *this;
1184*58b9f456SAndroid Build Coastguard Worker  }
1185*58b9f456SAndroid Build Coastguard Worker  string_type __pn_;
1186*58b9f456SAndroid Build Coastguard Worker};
1187*58b9f456SAndroid Build Coastguard Worker
1188*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
1189*58b9f456SAndroid Build Coastguard Worker  __lhs.swap(__rhs);
1190*58b9f456SAndroid Build Coastguard Worker}
1191*58b9f456SAndroid Build Coastguard Worker
1192*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1193*58b9f456SAndroid Build Coastguard Workersize_t hash_value(const path& __p) noexcept;
1194*58b9f456SAndroid Build Coastguard Worker
1195*58b9f456SAndroid Build Coastguard Workertemplate <class _Source>
1196*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
1197*58b9f456SAndroid Build Coastguard Worker    typename enable_if<__is_pathable<_Source>::value, path>::type
1198*58b9f456SAndroid Build Coastguard Worker    u8path(const _Source& __s) {
1199*58b9f456SAndroid Build Coastguard Worker  static_assert(
1200*58b9f456SAndroid Build Coastguard Worker      is_same<typename __is_pathable<_Source>::__char_type, char>::value,
1201*58b9f456SAndroid Build Coastguard Worker      "u8path(Source const&) requires Source have a character type of type "
1202*58b9f456SAndroid Build Coastguard Worker      "'char'");
1203*58b9f456SAndroid Build Coastguard Worker  return path(__s);
1204*58b9f456SAndroid Build Coastguard Worker}
1205*58b9f456SAndroid Build Coastguard Worker
1206*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIt>
1207*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
1208*58b9f456SAndroid Build Coastguard Worker    typename enable_if<__is_pathable<_InputIt>::value, path>::type
1209*58b9f456SAndroid Build Coastguard Worker    u8path(_InputIt __f, _InputIt __l) {
1210*58b9f456SAndroid Build Coastguard Worker  static_assert(
1211*58b9f456SAndroid Build Coastguard Worker      is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
1212*58b9f456SAndroid Build Coastguard Worker      "u8path(Iter, Iter) requires Iter have a value_type of type 'char'");
1213*58b9f456SAndroid Build Coastguard Worker  return path(__f, __l);
1214*58b9f456SAndroid Build Coastguard Worker}
1215*58b9f456SAndroid Build Coastguard Worker
1216*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS path::iterator {
1217*58b9f456SAndroid Build Coastguard Workerpublic:
1218*58b9f456SAndroid Build Coastguard Worker  enum _ParserState : unsigned char {
1219*58b9f456SAndroid Build Coastguard Worker    _Singular,
1220*58b9f456SAndroid Build Coastguard Worker    _BeforeBegin,
1221*58b9f456SAndroid Build Coastguard Worker    _InRootName,
1222*58b9f456SAndroid Build Coastguard Worker    _InRootDir,
1223*58b9f456SAndroid Build Coastguard Worker    _InFilenames,
1224*58b9f456SAndroid Build Coastguard Worker    _InTrailingSep,
1225*58b9f456SAndroid Build Coastguard Worker    _AtEnd
1226*58b9f456SAndroid Build Coastguard Worker  };
1227*58b9f456SAndroid Build Coastguard Worker
1228*58b9f456SAndroid Build Coastguard Workerpublic:
1229*58b9f456SAndroid Build Coastguard Worker  typedef bidirectional_iterator_tag iterator_category;
1230*58b9f456SAndroid Build Coastguard Worker
1231*58b9f456SAndroid Build Coastguard Worker  typedef path value_type;
1232*58b9f456SAndroid Build Coastguard Worker  typedef std::ptrdiff_t difference_type;
1233*58b9f456SAndroid Build Coastguard Worker  typedef const path* pointer;
1234*58b9f456SAndroid Build Coastguard Worker  typedef const path& reference;
1235*58b9f456SAndroid Build Coastguard Worker
1236*58b9f456SAndroid Build Coastguard Worker  typedef void
1237*58b9f456SAndroid Build Coastguard Worker      __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator
1238*58b9f456SAndroid Build Coastguard Worker
1239*58b9f456SAndroid Build Coastguard Workerpublic:
1240*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1241*58b9f456SAndroid Build Coastguard Worker  iterator()
1242*58b9f456SAndroid Build Coastguard Worker      : __stashed_elem_(), __path_ptr_(nullptr), __entry_(),
1243*58b9f456SAndroid Build Coastguard Worker        __state_(_Singular) {}
1244*58b9f456SAndroid Build Coastguard Worker
1245*58b9f456SAndroid Build Coastguard Worker  iterator(const iterator&) = default;
1246*58b9f456SAndroid Build Coastguard Worker  ~iterator() = default;
1247*58b9f456SAndroid Build Coastguard Worker
1248*58b9f456SAndroid Build Coastguard Worker  iterator& operator=(const iterator&) = default;
1249*58b9f456SAndroid Build Coastguard Worker
1250*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1251*58b9f456SAndroid Build Coastguard Worker  reference operator*() const { return __stashed_elem_; }
1252*58b9f456SAndroid Build Coastguard Worker
1253*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1254*58b9f456SAndroid Build Coastguard Worker  pointer operator->() const { return &__stashed_elem_; }
1255*58b9f456SAndroid Build Coastguard Worker
1256*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1257*58b9f456SAndroid Build Coastguard Worker  iterator& operator++() {
1258*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__state_ != _Singular,
1259*58b9f456SAndroid Build Coastguard Worker                   "attempting to increment a singular iterator");
1260*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__state_ != _AtEnd,
1261*58b9f456SAndroid Build Coastguard Worker                   "attempting to increment the end iterator");
1262*58b9f456SAndroid Build Coastguard Worker    return __increment();
1263*58b9f456SAndroid Build Coastguard Worker  }
1264*58b9f456SAndroid Build Coastguard Worker
1265*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1266*58b9f456SAndroid Build Coastguard Worker  iterator operator++(int) {
1267*58b9f456SAndroid Build Coastguard Worker    iterator __it(*this);
1268*58b9f456SAndroid Build Coastguard Worker    this->operator++();
1269*58b9f456SAndroid Build Coastguard Worker    return __it;
1270*58b9f456SAndroid Build Coastguard Worker  }
1271*58b9f456SAndroid Build Coastguard Worker
1272*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1273*58b9f456SAndroid Build Coastguard Worker  iterator& operator--() {
1274*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__state_ != _Singular,
1275*58b9f456SAndroid Build Coastguard Worker                   "attempting to decrement a singular iterator");
1276*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
1277*58b9f456SAndroid Build Coastguard Worker                   "attempting to decrement the begin iterator");
1278*58b9f456SAndroid Build Coastguard Worker    return __decrement();
1279*58b9f456SAndroid Build Coastguard Worker  }
1280*58b9f456SAndroid Build Coastguard Worker
1281*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1282*58b9f456SAndroid Build Coastguard Worker  iterator operator--(int) {
1283*58b9f456SAndroid Build Coastguard Worker    iterator __it(*this);
1284*58b9f456SAndroid Build Coastguard Worker    this->operator--();
1285*58b9f456SAndroid Build Coastguard Worker    return __it;
1286*58b9f456SAndroid Build Coastguard Worker  }
1287*58b9f456SAndroid Build Coastguard Worker
1288*58b9f456SAndroid Build Coastguard Workerprivate:
1289*58b9f456SAndroid Build Coastguard Worker  friend class path;
1290*58b9f456SAndroid Build Coastguard Worker
1291*58b9f456SAndroid Build Coastguard Worker  inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&,
1292*58b9f456SAndroid Build Coastguard Worker                                                          const iterator&);
1293*58b9f456SAndroid Build Coastguard Worker
1294*58b9f456SAndroid Build Coastguard Worker  iterator& __increment();
1295*58b9f456SAndroid Build Coastguard Worker  iterator& __decrement();
1296*58b9f456SAndroid Build Coastguard Worker
1297*58b9f456SAndroid Build Coastguard Worker  path __stashed_elem_;
1298*58b9f456SAndroid Build Coastguard Worker  const path* __path_ptr_;
1299*58b9f456SAndroid Build Coastguard Worker  path::__string_view __entry_;
1300*58b9f456SAndroid Build Coastguard Worker  _ParserState __state_;
1301*58b9f456SAndroid Build Coastguard Worker};
1302*58b9f456SAndroid Build Coastguard Worker
1303*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs,
1304*58b9f456SAndroid Build Coastguard Worker                                                 const path::iterator& __rhs) {
1305*58b9f456SAndroid Build Coastguard Worker  return __lhs.__path_ptr_ == __rhs.__path_ptr_ &&
1306*58b9f456SAndroid Build Coastguard Worker         __lhs.__entry_.data() == __rhs.__entry_.data();
1307*58b9f456SAndroid Build Coastguard Worker}
1308*58b9f456SAndroid Build Coastguard Worker
1309*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs,
1310*58b9f456SAndroid Build Coastguard Worker                                                 const path::iterator& __rhs) {
1311*58b9f456SAndroid Build Coastguard Worker  return !(__lhs == __rhs);
1312*58b9f456SAndroid Build Coastguard Worker}
1313*58b9f456SAndroid Build Coastguard Worker
1314*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error {
1315*58b9f456SAndroid Build Coastguard Workerpublic:
1316*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1317*58b9f456SAndroid Build Coastguard Worker  filesystem_error(const string& __what, error_code __ec)
1318*58b9f456SAndroid Build Coastguard Worker      : system_error(__ec, __what),
1319*58b9f456SAndroid Build Coastguard Worker        __storage_(make_shared<_Storage>(path(), path())) {
1320*58b9f456SAndroid Build Coastguard Worker    __create_what(0);
1321*58b9f456SAndroid Build Coastguard Worker  }
1322*58b9f456SAndroid Build Coastguard Worker
1323*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1324*58b9f456SAndroid Build Coastguard Worker  filesystem_error(const string& __what, const path& __p1, error_code __ec)
1325*58b9f456SAndroid Build Coastguard Worker      : system_error(__ec, __what),
1326*58b9f456SAndroid Build Coastguard Worker        __storage_(make_shared<_Storage>(__p1, path())) {
1327*58b9f456SAndroid Build Coastguard Worker    __create_what(1);
1328*58b9f456SAndroid Build Coastguard Worker  }
1329*58b9f456SAndroid Build Coastguard Worker
1330*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1331*58b9f456SAndroid Build Coastguard Worker  filesystem_error(const string& __what, const path& __p1, const path& __p2,
1332*58b9f456SAndroid Build Coastguard Worker                   error_code __ec)
1333*58b9f456SAndroid Build Coastguard Worker      : system_error(__ec, __what),
1334*58b9f456SAndroid Build Coastguard Worker        __storage_(make_shared<_Storage>(__p1, __p2)) {
1335*58b9f456SAndroid Build Coastguard Worker    __create_what(2);
1336*58b9f456SAndroid Build Coastguard Worker  }
1337*58b9f456SAndroid Build Coastguard Worker
1338*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1339*58b9f456SAndroid Build Coastguard Worker  const path& path1() const noexcept { return __storage_->__p1_; }
1340*58b9f456SAndroid Build Coastguard Worker
1341*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1342*58b9f456SAndroid Build Coastguard Worker  const path& path2() const noexcept { return __storage_->__p2_; }
1343*58b9f456SAndroid Build Coastguard Worker
1344*58b9f456SAndroid Build Coastguard Worker  ~filesystem_error() override; // key function
1345*58b9f456SAndroid Build Coastguard Worker
1346*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1347*58b9f456SAndroid Build Coastguard Worker  const char* what() const noexcept override {
1348*58b9f456SAndroid Build Coastguard Worker    return __storage_->__what_.c_str();
1349*58b9f456SAndroid Build Coastguard Worker  }
1350*58b9f456SAndroid Build Coastguard Worker
1351*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
1352*58b9f456SAndroid Build Coastguard Worker  void __create_what(int __num_paths);
1353*58b9f456SAndroid Build Coastguard Worker
1354*58b9f456SAndroid Build Coastguard Workerprivate:
1355*58b9f456SAndroid Build Coastguard Worker  struct _Storage {
1356*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1357*58b9f456SAndroid Build Coastguard Worker    _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
1358*58b9f456SAndroid Build Coastguard Worker
1359*58b9f456SAndroid Build Coastguard Worker    path __p1_;
1360*58b9f456SAndroid Build Coastguard Worker    path __p2_;
1361*58b9f456SAndroid Build Coastguard Worker    string __what_;
1362*58b9f456SAndroid Build Coastguard Worker  };
1363*58b9f456SAndroid Build Coastguard Worker  shared_ptr<_Storage> __storage_;
1364*58b9f456SAndroid Build Coastguard Worker};
1365*58b9f456SAndroid Build Coastguard Worker
1366*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
1367*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
1368*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1369*58b9f456SAndroid Build Coastguard Worker    void
1370*58b9f456SAndroid Build Coastguard Worker    __throw_filesystem_error(_Args&&... __args) {
1371*58b9f456SAndroid Build Coastguard Worker  throw filesystem_error(std::forward<_Args>(__args)...);
1372*58b9f456SAndroid Build Coastguard Worker}
1373*58b9f456SAndroid Build Coastguard Worker#else
1374*58b9f456SAndroid Build Coastguard Worker    void
1375*58b9f456SAndroid Build Coastguard Worker    __throw_filesystem_error(_Args&&...) {
1376*58b9f456SAndroid Build Coastguard Worker  _VSTD::abort();
1377*58b9f456SAndroid Build Coastguard Worker}
1378*58b9f456SAndroid Build Coastguard Worker#endif
1379*58b9f456SAndroid Build Coastguard Worker
1380*58b9f456SAndroid Build Coastguard Worker// operational functions
1381*58b9f456SAndroid Build Coastguard Worker
1382*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1383*58b9f456SAndroid Build Coastguard Workerpath __absolute(const path&, error_code* __ec = nullptr);
1384*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1385*58b9f456SAndroid Build Coastguard Workerpath __canonical(const path&, error_code* __ec = nullptr);
1386*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1387*58b9f456SAndroid Build Coastguard Workervoid __copy(const path& __from, const path& __to, copy_options __opt,
1388*58b9f456SAndroid Build Coastguard Worker            error_code* __ec = nullptr);
1389*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1390*58b9f456SAndroid Build Coastguard Workerbool __copy_file(const path& __from, const path& __to, copy_options __opt,
1391*58b9f456SAndroid Build Coastguard Worker                 error_code* __ec = nullptr);
1392*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1393*58b9f456SAndroid Build Coastguard Workervoid __copy_symlink(const path& __existing_symlink, const path& __new_symlink,
1394*58b9f456SAndroid Build Coastguard Worker                    error_code* __ec = nullptr);
1395*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1396*58b9f456SAndroid Build Coastguard Workerbool __create_directories(const path& p, error_code* ec = nullptr);
1397*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1398*58b9f456SAndroid Build Coastguard Workerbool __create_directory(const path& p, error_code* ec = nullptr);
1399*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1400*58b9f456SAndroid Build Coastguard Workerbool __create_directory(const path& p, const path& attributes,
1401*58b9f456SAndroid Build Coastguard Worker                        error_code* ec = nullptr);
1402*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1403*58b9f456SAndroid Build Coastguard Workervoid __create_directory_symlink(const path& __to, const path& __new_symlink,
1404*58b9f456SAndroid Build Coastguard Worker                                error_code* __ec = nullptr);
1405*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1406*58b9f456SAndroid Build Coastguard Workervoid __create_hard_link(const path& __to, const path& __new_hard_link,
1407*58b9f456SAndroid Build Coastguard Worker                        error_code* __ec = nullptr);
1408*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1409*58b9f456SAndroid Build Coastguard Workervoid __create_symlink(const path& __to, const path& __new_symlink,
1410*58b9f456SAndroid Build Coastguard Worker                      error_code* __ec = nullptr);
1411*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1412*58b9f456SAndroid Build Coastguard Workerpath __current_path(error_code* __ec = nullptr);
1413*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1414*58b9f456SAndroid Build Coastguard Workervoid __current_path(const path&, error_code* __ec = nullptr);
1415*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1416*58b9f456SAndroid Build Coastguard Workerbool __equivalent(const path&, const path&, error_code* __ec = nullptr);
1417*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1418*58b9f456SAndroid Build Coastguard Workeruintmax_t __file_size(const path&, error_code* __ec = nullptr);
1419*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1420*58b9f456SAndroid Build Coastguard Workeruintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);
1421*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1422*58b9f456SAndroid Build Coastguard Workerbool __fs_is_empty(const path& p, error_code* ec = nullptr);
1423*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1424*58b9f456SAndroid Build Coastguard Workerfile_time_type __last_write_time(const path& p, error_code* ec = nullptr);
1425*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1426*58b9f456SAndroid Build Coastguard Workervoid __last_write_time(const path& p, file_time_type new_time,
1427*58b9f456SAndroid Build Coastguard Worker                       error_code* ec = nullptr);
1428*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1429*58b9f456SAndroid Build Coastguard Workervoid __permissions(const path&, perms, perm_options, error_code* = nullptr);
1430*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1431*58b9f456SAndroid Build Coastguard Workerpath __read_symlink(const path& p, error_code* ec = nullptr);
1432*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1433*58b9f456SAndroid Build Coastguard Workerbool __remove(const path& p, error_code* ec = nullptr);
1434*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1435*58b9f456SAndroid Build Coastguard Workeruintmax_t __remove_all(const path& p, error_code* ec = nullptr);
1436*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1437*58b9f456SAndroid Build Coastguard Workervoid __rename(const path& from, const path& to, error_code* ec = nullptr);
1438*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1439*58b9f456SAndroid Build Coastguard Workervoid __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr);
1440*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1441*58b9f456SAndroid Build Coastguard Workerspace_info __space(const path&, error_code* __ec = nullptr);
1442*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1443*58b9f456SAndroid Build Coastguard Workerfile_status __status(const path&, error_code* __ec = nullptr);
1444*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1445*58b9f456SAndroid Build Coastguard Workerfile_status __symlink_status(const path&, error_code* __ec = nullptr);
1446*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1447*58b9f456SAndroid Build Coastguard Workerpath __system_complete(const path&, error_code* __ec = nullptr);
1448*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1449*58b9f456SAndroid Build Coastguard Workerpath __temp_directory_path(error_code* __ec = nullptr);
1450*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
1451*58b9f456SAndroid Build Coastguard Workerpath __weakly_canonical(path const& __p, error_code* __ec = nullptr);
1452*58b9f456SAndroid Build Coastguard Worker
1453*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path current_path() {
1454*58b9f456SAndroid Build Coastguard Worker  return __current_path();
1455*58b9f456SAndroid Build Coastguard Worker}
1456*58b9f456SAndroid Build Coastguard Worker
1457*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) {
1458*58b9f456SAndroid Build Coastguard Worker  return __current_path(&__ec);
1459*58b9f456SAndroid Build Coastguard Worker}
1460*58b9f456SAndroid Build Coastguard Worker
1461*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) {
1462*58b9f456SAndroid Build Coastguard Worker  __current_path(__p);
1463*58b9f456SAndroid Build Coastguard Worker}
1464*58b9f456SAndroid Build Coastguard Worker
1465*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p,
1466*58b9f456SAndroid Build Coastguard Worker                                                   error_code& __ec) noexcept {
1467*58b9f456SAndroid Build Coastguard Worker  __current_path(__p, &__ec);
1468*58b9f456SAndroid Build Coastguard Worker}
1469*58b9f456SAndroid Build Coastguard Worker
1470*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) {
1471*58b9f456SAndroid Build Coastguard Worker  return __absolute(__p);
1472*58b9f456SAndroid Build Coastguard Worker}
1473*58b9f456SAndroid Build Coastguard Worker
1474*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p,
1475*58b9f456SAndroid Build Coastguard Worker                                               error_code& __ec) {
1476*58b9f456SAndroid Build Coastguard Worker  return __absolute(__p, &__ec);
1477*58b9f456SAndroid Build Coastguard Worker}
1478*58b9f456SAndroid Build Coastguard Worker
1479*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) {
1480*58b9f456SAndroid Build Coastguard Worker  return __canonical(__p);
1481*58b9f456SAndroid Build Coastguard Worker}
1482*58b9f456SAndroid Build Coastguard Worker
1483*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p,
1484*58b9f456SAndroid Build Coastguard Worker                                                error_code& __ec) {
1485*58b9f456SAndroid Build Coastguard Worker  return __canonical(__p, &__ec);
1486*58b9f456SAndroid Build Coastguard Worker}
1487*58b9f456SAndroid Build Coastguard Worker
1488*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from,
1489*58b9f456SAndroid Build Coastguard Worker                                           const path& __to) {
1490*58b9f456SAndroid Build Coastguard Worker  __copy(__from, __to, copy_options::none);
1491*58b9f456SAndroid Build Coastguard Worker}
1492*58b9f456SAndroid Build Coastguard Worker
1493*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to,
1494*58b9f456SAndroid Build Coastguard Worker                                           error_code& __ec) {
1495*58b9f456SAndroid Build Coastguard Worker  __copy(__from, __to, copy_options::none, &__ec);
1496*58b9f456SAndroid Build Coastguard Worker}
1497*58b9f456SAndroid Build Coastguard Worker
1498*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to,
1499*58b9f456SAndroid Build Coastguard Worker                                           copy_options __opt) {
1500*58b9f456SAndroid Build Coastguard Worker  __copy(__from, __to, __opt);
1501*58b9f456SAndroid Build Coastguard Worker}
1502*58b9f456SAndroid Build Coastguard Worker
1503*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to,
1504*58b9f456SAndroid Build Coastguard Worker                                           copy_options __opt,
1505*58b9f456SAndroid Build Coastguard Worker                                           error_code& __ec) {
1506*58b9f456SAndroid Build Coastguard Worker  __copy(__from, __to, __opt, &__ec);
1507*58b9f456SAndroid Build Coastguard Worker}
1508*58b9f456SAndroid Build Coastguard Worker
1509*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from,
1510*58b9f456SAndroid Build Coastguard Worker                                                const path& __to) {
1511*58b9f456SAndroid Build Coastguard Worker  return __copy_file(__from, __to, copy_options::none);
1512*58b9f456SAndroid Build Coastguard Worker}
1513*58b9f456SAndroid Build Coastguard Worker
1514*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1515*58b9f456SAndroid Build Coastguard Workercopy_file(const path& __from, const path& __to, error_code& __ec) {
1516*58b9f456SAndroid Build Coastguard Worker  return __copy_file(__from, __to, copy_options::none, &__ec);
1517*58b9f456SAndroid Build Coastguard Worker}
1518*58b9f456SAndroid Build Coastguard Worker
1519*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1520*58b9f456SAndroid Build Coastguard Workercopy_file(const path& __from, const path& __to, copy_options __opt) {
1521*58b9f456SAndroid Build Coastguard Worker  return __copy_file(__from, __to, __opt);
1522*58b9f456SAndroid Build Coastguard Worker}
1523*58b9f456SAndroid Build Coastguard Worker
1524*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from,
1525*58b9f456SAndroid Build Coastguard Worker                                                const path& __to,
1526*58b9f456SAndroid Build Coastguard Worker                                                copy_options __opt,
1527*58b9f456SAndroid Build Coastguard Worker                                                error_code& __ec) {
1528*58b9f456SAndroid Build Coastguard Worker  return __copy_file(__from, __to, __opt, &__ec);
1529*58b9f456SAndroid Build Coastguard Worker}
1530*58b9f456SAndroid Build Coastguard Worker
1531*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __existing,
1532*58b9f456SAndroid Build Coastguard Worker                                                   const path& __new) {
1533*58b9f456SAndroid Build Coastguard Worker  __copy_symlink(__existing, __new);
1534*58b9f456SAndroid Build Coastguard Worker}
1535*58b9f456SAndroid Build Coastguard Worker
1536*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1537*58b9f456SAndroid Build Coastguard Workercopy_symlink(const path& __ext, const path& __new, error_code& __ec) noexcept {
1538*58b9f456SAndroid Build Coastguard Worker  __copy_symlink(__ext, __new, &__ec);
1539*58b9f456SAndroid Build Coastguard Worker}
1540*58b9f456SAndroid Build Coastguard Worker
1541*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) {
1542*58b9f456SAndroid Build Coastguard Worker  return __create_directories(__p);
1543*58b9f456SAndroid Build Coastguard Worker}
1544*58b9f456SAndroid Build Coastguard Worker
1545*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p,
1546*58b9f456SAndroid Build Coastguard Worker                                                         error_code& __ec) {
1547*58b9f456SAndroid Build Coastguard Worker  return __create_directories(__p, &__ec);
1548*58b9f456SAndroid Build Coastguard Worker}
1549*58b9f456SAndroid Build Coastguard Worker
1550*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) {
1551*58b9f456SAndroid Build Coastguard Worker  return __create_directory(__p);
1552*58b9f456SAndroid Build Coastguard Worker}
1553*58b9f456SAndroid Build Coastguard Worker
1554*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1555*58b9f456SAndroid Build Coastguard Workercreate_directory(const path& __p, error_code& __ec) noexcept {
1556*58b9f456SAndroid Build Coastguard Worker  return __create_directory(__p, &__ec);
1557*58b9f456SAndroid Build Coastguard Worker}
1558*58b9f456SAndroid Build Coastguard Worker
1559*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p,
1560*58b9f456SAndroid Build Coastguard Worker                                                       const path& __attrs) {
1561*58b9f456SAndroid Build Coastguard Worker  return __create_directory(__p, __attrs);
1562*58b9f456SAndroid Build Coastguard Worker}
1563*58b9f456SAndroid Build Coastguard Worker
1564*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1565*58b9f456SAndroid Build Coastguard Workercreate_directory(const path& __p, const path& __attrs,
1566*58b9f456SAndroid Build Coastguard Worker                 error_code& __ec) noexcept {
1567*58b9f456SAndroid Build Coastguard Worker  return __create_directory(__p, __attrs, &__ec);
1568*58b9f456SAndroid Build Coastguard Worker}
1569*58b9f456SAndroid Build Coastguard Worker
1570*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1571*58b9f456SAndroid Build Coastguard Workercreate_directory_symlink(const path& __to, const path& __new) {
1572*58b9f456SAndroid Build Coastguard Worker  __create_directory_symlink(__to, __new);
1573*58b9f456SAndroid Build Coastguard Worker}
1574*58b9f456SAndroid Build Coastguard Worker
1575*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1576*58b9f456SAndroid Build Coastguard Workercreate_directory_symlink(const path& __to, const path& __new,
1577*58b9f456SAndroid Build Coastguard Worker                         error_code& __ec) noexcept {
1578*58b9f456SAndroid Build Coastguard Worker  __create_directory_symlink(__to, __new, &__ec);
1579*58b9f456SAndroid Build Coastguard Worker}
1580*58b9f456SAndroid Build Coastguard Worker
1581*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __to,
1582*58b9f456SAndroid Build Coastguard Worker                                                       const path& __new) {
1583*58b9f456SAndroid Build Coastguard Worker  __create_hard_link(__to, __new);
1584*58b9f456SAndroid Build Coastguard Worker}
1585*58b9f456SAndroid Build Coastguard Worker
1586*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1587*58b9f456SAndroid Build Coastguard Workercreate_hard_link(const path& __to, const path& __new,
1588*58b9f456SAndroid Build Coastguard Worker                 error_code& __ec) noexcept {
1589*58b9f456SAndroid Build Coastguard Worker  __create_hard_link(__to, __new, &__ec);
1590*58b9f456SAndroid Build Coastguard Worker}
1591*58b9f456SAndroid Build Coastguard Worker
1592*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __to,
1593*58b9f456SAndroid Build Coastguard Worker                                                     const path& __new) {
1594*58b9f456SAndroid Build Coastguard Worker  __create_symlink(__to, __new);
1595*58b9f456SAndroid Build Coastguard Worker}
1596*58b9f456SAndroid Build Coastguard Worker
1597*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1598*58b9f456SAndroid Build Coastguard Workercreate_symlink(const path& __to, const path& __new, error_code& __ec) noexcept {
1599*58b9f456SAndroid Build Coastguard Worker  return __create_symlink(__to, __new, &__ec);
1600*58b9f456SAndroid Build Coastguard Worker}
1601*58b9f456SAndroid Build Coastguard Worker
1602*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept {
1603*58b9f456SAndroid Build Coastguard Worker  return __s.type() != file_type::none;
1604*58b9f456SAndroid Build Coastguard Worker}
1605*58b9f456SAndroid Build Coastguard Worker
1606*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept {
1607*58b9f456SAndroid Build Coastguard Worker  return status_known(__s) && __s.type() != file_type::not_found;
1608*58b9f456SAndroid Build Coastguard Worker}
1609*58b9f456SAndroid Build Coastguard Worker
1610*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) {
1611*58b9f456SAndroid Build Coastguard Worker  return exists(__status(__p));
1612*58b9f456SAndroid Build Coastguard Worker}
1613*58b9f456SAndroid Build Coastguard Worker
1614*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p,
1615*58b9f456SAndroid Build Coastguard Worker                                             error_code& __ec) noexcept {
1616*58b9f456SAndroid Build Coastguard Worker  auto __s = __status(__p, &__ec);
1617*58b9f456SAndroid Build Coastguard Worker  if (status_known(__s))
1618*58b9f456SAndroid Build Coastguard Worker    __ec.clear();
1619*58b9f456SAndroid Build Coastguard Worker  return exists(__s);
1620*58b9f456SAndroid Build Coastguard Worker}
1621*58b9f456SAndroid Build Coastguard Worker
1622*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1,
1623*58b9f456SAndroid Build Coastguard Worker                                                 const path& __p2) {
1624*58b9f456SAndroid Build Coastguard Worker  return __equivalent(__p1, __p2);
1625*58b9f456SAndroid Build Coastguard Worker}
1626*58b9f456SAndroid Build Coastguard Worker
1627*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1628*58b9f456SAndroid Build Coastguard Workerequivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept {
1629*58b9f456SAndroid Build Coastguard Worker  return __equivalent(__p1, __p2, &__ec);
1630*58b9f456SAndroid Build Coastguard Worker}
1631*58b9f456SAndroid Build Coastguard Worker
1632*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) {
1633*58b9f456SAndroid Build Coastguard Worker  return __file_size(__p);
1634*58b9f456SAndroid Build Coastguard Worker}
1635*58b9f456SAndroid Build Coastguard Worker
1636*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY uintmax_t
1637*58b9f456SAndroid Build Coastguard Workerfile_size(const path& __p, error_code& __ec) noexcept {
1638*58b9f456SAndroid Build Coastguard Worker  return __file_size(__p, &__ec);
1639*58b9f456SAndroid Build Coastguard Worker}
1640*58b9f456SAndroid Build Coastguard Worker
1641*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) {
1642*58b9f456SAndroid Build Coastguard Worker  return __hard_link_count(__p);
1643*58b9f456SAndroid Build Coastguard Worker}
1644*58b9f456SAndroid Build Coastguard Worker
1645*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY uintmax_t
1646*58b9f456SAndroid Build Coastguard Workerhard_link_count(const path& __p, error_code& __ec) noexcept {
1647*58b9f456SAndroid Build Coastguard Worker  return __hard_link_count(__p, &__ec);
1648*58b9f456SAndroid Build Coastguard Worker}
1649*58b9f456SAndroid Build Coastguard Worker
1650*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept {
1651*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::block;
1652*58b9f456SAndroid Build Coastguard Worker}
1653*58b9f456SAndroid Build Coastguard Worker
1654*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) {
1655*58b9f456SAndroid Build Coastguard Worker  return is_block_file(__status(__p));
1656*58b9f456SAndroid Build Coastguard Worker}
1657*58b9f456SAndroid Build Coastguard Worker
1658*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p,
1659*58b9f456SAndroid Build Coastguard Worker                                                    error_code& __ec) noexcept {
1660*58b9f456SAndroid Build Coastguard Worker  return is_block_file(__status(__p, &__ec));
1661*58b9f456SAndroid Build Coastguard Worker}
1662*58b9f456SAndroid Build Coastguard Worker
1663*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1664*58b9f456SAndroid Build Coastguard Workeris_character_file(file_status __s) noexcept {
1665*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::character;
1666*58b9f456SAndroid Build Coastguard Worker}
1667*58b9f456SAndroid Build Coastguard Worker
1668*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) {
1669*58b9f456SAndroid Build Coastguard Worker  return is_character_file(__status(__p));
1670*58b9f456SAndroid Build Coastguard Worker}
1671*58b9f456SAndroid Build Coastguard Worker
1672*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1673*58b9f456SAndroid Build Coastguard Workeris_character_file(const path& __p, error_code& __ec) noexcept {
1674*58b9f456SAndroid Build Coastguard Worker  return is_character_file(__status(__p, &__ec));
1675*58b9f456SAndroid Build Coastguard Worker}
1676*58b9f456SAndroid Build Coastguard Worker
1677*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept {
1678*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::directory;
1679*58b9f456SAndroid Build Coastguard Worker}
1680*58b9f456SAndroid Build Coastguard Worker
1681*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) {
1682*58b9f456SAndroid Build Coastguard Worker  return is_directory(__status(__p));
1683*58b9f456SAndroid Build Coastguard Worker}
1684*58b9f456SAndroid Build Coastguard Worker
1685*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p,
1686*58b9f456SAndroid Build Coastguard Worker                                                   error_code& __ec) noexcept {
1687*58b9f456SAndroid Build Coastguard Worker  return is_directory(__status(__p, &__ec));
1688*58b9f456SAndroid Build Coastguard Worker}
1689*58b9f456SAndroid Build Coastguard Worker
1690*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) {
1691*58b9f456SAndroid Build Coastguard Worker  return __fs_is_empty(__p);
1692*58b9f456SAndroid Build Coastguard Worker}
1693*58b9f456SAndroid Build Coastguard Worker
1694*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p,
1695*58b9f456SAndroid Build Coastguard Worker                                               error_code& __ec) {
1696*58b9f456SAndroid Build Coastguard Worker  return __fs_is_empty(__p, &__ec);
1697*58b9f456SAndroid Build Coastguard Worker}
1698*58b9f456SAndroid Build Coastguard Worker
1699*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept {
1700*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::fifo;
1701*58b9f456SAndroid Build Coastguard Worker}
1702*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) {
1703*58b9f456SAndroid Build Coastguard Worker  return is_fifo(__status(__p));
1704*58b9f456SAndroid Build Coastguard Worker}
1705*58b9f456SAndroid Build Coastguard Worker
1706*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p,
1707*58b9f456SAndroid Build Coastguard Worker                                              error_code& __ec) noexcept {
1708*58b9f456SAndroid Build Coastguard Worker  return is_fifo(__status(__p, &__ec));
1709*58b9f456SAndroid Build Coastguard Worker}
1710*58b9f456SAndroid Build Coastguard Worker
1711*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1712*58b9f456SAndroid Build Coastguard Workeris_regular_file(file_status __s) noexcept {
1713*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::regular;
1714*58b9f456SAndroid Build Coastguard Worker}
1715*58b9f456SAndroid Build Coastguard Worker
1716*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) {
1717*58b9f456SAndroid Build Coastguard Worker  return is_regular_file(__status(__p));
1718*58b9f456SAndroid Build Coastguard Worker}
1719*58b9f456SAndroid Build Coastguard Worker
1720*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
1721*58b9f456SAndroid Build Coastguard Workeris_regular_file(const path& __p, error_code& __ec) noexcept {
1722*58b9f456SAndroid Build Coastguard Worker  return is_regular_file(__status(__p, &__ec));
1723*58b9f456SAndroid Build Coastguard Worker}
1724*58b9f456SAndroid Build Coastguard Worker
1725*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept {
1726*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::socket;
1727*58b9f456SAndroid Build Coastguard Worker}
1728*58b9f456SAndroid Build Coastguard Worker
1729*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) {
1730*58b9f456SAndroid Build Coastguard Worker  return is_socket(__status(__p));
1731*58b9f456SAndroid Build Coastguard Worker}
1732*58b9f456SAndroid Build Coastguard Worker
1733*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p,
1734*58b9f456SAndroid Build Coastguard Worker                                                error_code& __ec) noexcept {
1735*58b9f456SAndroid Build Coastguard Worker  return is_socket(__status(__p, &__ec));
1736*58b9f456SAndroid Build Coastguard Worker}
1737*58b9f456SAndroid Build Coastguard Worker
1738*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept {
1739*58b9f456SAndroid Build Coastguard Worker  return __s.type() == file_type::symlink;
1740*58b9f456SAndroid Build Coastguard Worker}
1741*58b9f456SAndroid Build Coastguard Worker
1742*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) {
1743*58b9f456SAndroid Build Coastguard Worker  return is_symlink(__symlink_status(__p));
1744*58b9f456SAndroid Build Coastguard Worker}
1745*58b9f456SAndroid Build Coastguard Worker
1746*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p,
1747*58b9f456SAndroid Build Coastguard Worker                                                 error_code& __ec) noexcept {
1748*58b9f456SAndroid Build Coastguard Worker  return is_symlink(__symlink_status(__p, &__ec));
1749*58b9f456SAndroid Build Coastguard Worker}
1750*58b9f456SAndroid Build Coastguard Worker
1751*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept {
1752*58b9f456SAndroid Build Coastguard Worker  return exists(__s) && !is_regular_file(__s) && !is_directory(__s) &&
1753*58b9f456SAndroid Build Coastguard Worker         !is_symlink(__s);
1754*58b9f456SAndroid Build Coastguard Worker}
1755*58b9f456SAndroid Build Coastguard Worker
1756*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) {
1757*58b9f456SAndroid Build Coastguard Worker  return is_other(__status(__p));
1758*58b9f456SAndroid Build Coastguard Worker}
1759*58b9f456SAndroid Build Coastguard Worker
1760*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p,
1761*58b9f456SAndroid Build Coastguard Worker                                               error_code& __ec) noexcept {
1762*58b9f456SAndroid Build Coastguard Worker  return is_other(__status(__p, &__ec));
1763*58b9f456SAndroid Build Coastguard Worker}
1764*58b9f456SAndroid Build Coastguard Worker
1765*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY file_time_type
1766*58b9f456SAndroid Build Coastguard Workerlast_write_time(const path& __p) {
1767*58b9f456SAndroid Build Coastguard Worker  return __last_write_time(__p);
1768*58b9f456SAndroid Build Coastguard Worker}
1769*58b9f456SAndroid Build Coastguard Worker
1770*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY file_time_type
1771*58b9f456SAndroid Build Coastguard Workerlast_write_time(const path& __p, error_code& __ec) noexcept {
1772*58b9f456SAndroid Build Coastguard Worker  return __last_write_time(__p, &__ec);
1773*58b9f456SAndroid Build Coastguard Worker}
1774*58b9f456SAndroid Build Coastguard Worker
1775*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p,
1776*58b9f456SAndroid Build Coastguard Worker                                                      file_time_type __t) {
1777*58b9f456SAndroid Build Coastguard Worker  __last_write_time(__p, __t);
1778*58b9f456SAndroid Build Coastguard Worker}
1779*58b9f456SAndroid Build Coastguard Worker
1780*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1781*58b9f456SAndroid Build Coastguard Workerlast_write_time(const path& __p, file_time_type __t,
1782*58b9f456SAndroid Build Coastguard Worker                error_code& __ec) noexcept {
1783*58b9f456SAndroid Build Coastguard Worker  __last_write_time(__p, __t, &__ec);
1784*58b9f456SAndroid Build Coastguard Worker}
1785*58b9f456SAndroid Build Coastguard Worker
1786*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1787*58b9f456SAndroid Build Coastguard Workerpermissions(const path& __p, perms __prms,
1788*58b9f456SAndroid Build Coastguard Worker            perm_options __opts = perm_options::replace) {
1789*58b9f456SAndroid Build Coastguard Worker  __permissions(__p, __prms, __opts);
1790*58b9f456SAndroid Build Coastguard Worker}
1791*58b9f456SAndroid Build Coastguard Worker
1792*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms,
1793*58b9f456SAndroid Build Coastguard Worker                                                  error_code& __ec) noexcept {
1794*58b9f456SAndroid Build Coastguard Worker  __permissions(__p, __prms, perm_options::replace, &__ec);
1795*58b9f456SAndroid Build Coastguard Worker}
1796*58b9f456SAndroid Build Coastguard Worker
1797*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms,
1798*58b9f456SAndroid Build Coastguard Worker                                                  perm_options __opts,
1799*58b9f456SAndroid Build Coastguard Worker                                                  error_code& __ec) {
1800*58b9f456SAndroid Build Coastguard Worker  __permissions(__p, __prms, __opts, &__ec);
1801*58b9f456SAndroid Build Coastguard Worker}
1802*58b9f456SAndroid Build Coastguard Worker
1803*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p,
1804*58b9f456SAndroid Build Coastguard Worker                                                const path& __base,
1805*58b9f456SAndroid Build Coastguard Worker                                                error_code& __ec) {
1806*58b9f456SAndroid Build Coastguard Worker  path __tmp = __weakly_canonical(__p, &__ec);
1807*58b9f456SAndroid Build Coastguard Worker  if (__ec)
1808*58b9f456SAndroid Build Coastguard Worker    return {};
1809*58b9f456SAndroid Build Coastguard Worker  path __tmp_base = __weakly_canonical(__base, &__ec);
1810*58b9f456SAndroid Build Coastguard Worker  if (__ec)
1811*58b9f456SAndroid Build Coastguard Worker    return {};
1812*58b9f456SAndroid Build Coastguard Worker  return __tmp.lexically_proximate(__tmp_base);
1813*58b9f456SAndroid Build Coastguard Worker}
1814*58b9f456SAndroid Build Coastguard Worker
1815*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p,
1816*58b9f456SAndroid Build Coastguard Worker                                                error_code& __ec) {
1817*58b9f456SAndroid Build Coastguard Worker  return proximate(__p, current_path(), __ec);
1818*58b9f456SAndroid Build Coastguard Worker}
1819*58b9f456SAndroid Build Coastguard Worker
1820*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path
1821*58b9f456SAndroid Build Coastguard Workerproximate(const path& __p, const path& __base = current_path()) {
1822*58b9f456SAndroid Build Coastguard Worker  return __weakly_canonical(__p).lexically_proximate(
1823*58b9f456SAndroid Build Coastguard Worker      __weakly_canonical(__base));
1824*58b9f456SAndroid Build Coastguard Worker}
1825*58b9f456SAndroid Build Coastguard Worker
1826*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) {
1827*58b9f456SAndroid Build Coastguard Worker  return __read_symlink(__p);
1828*58b9f456SAndroid Build Coastguard Worker}
1829*58b9f456SAndroid Build Coastguard Worker
1830*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p,
1831*58b9f456SAndroid Build Coastguard Worker                                                   error_code& __ec) {
1832*58b9f456SAndroid Build Coastguard Worker  return __read_symlink(__p, &__ec);
1833*58b9f456SAndroid Build Coastguard Worker}
1834*58b9f456SAndroid Build Coastguard Worker
1835*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p,
1836*58b9f456SAndroid Build Coastguard Worker                                               const path& __base,
1837*58b9f456SAndroid Build Coastguard Worker                                               error_code& __ec) {
1838*58b9f456SAndroid Build Coastguard Worker  path __tmp = __weakly_canonical(__p, &__ec);
1839*58b9f456SAndroid Build Coastguard Worker  if (__ec)
1840*58b9f456SAndroid Build Coastguard Worker    return path();
1841*58b9f456SAndroid Build Coastguard Worker  path __tmpbase = __weakly_canonical(__base, &__ec);
1842*58b9f456SAndroid Build Coastguard Worker  if (__ec)
1843*58b9f456SAndroid Build Coastguard Worker    return path();
1844*58b9f456SAndroid Build Coastguard Worker  return __tmp.lexically_relative(__tmpbase);
1845*58b9f456SAndroid Build Coastguard Worker}
1846*58b9f456SAndroid Build Coastguard Worker
1847*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p,
1848*58b9f456SAndroid Build Coastguard Worker                                               error_code& __ec) {
1849*58b9f456SAndroid Build Coastguard Worker  return relative(__p, current_path(), __ec);
1850*58b9f456SAndroid Build Coastguard Worker}
1851*58b9f456SAndroid Build Coastguard Worker
1852*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path
1853*58b9f456SAndroid Build Coastguard Workerrelative(const path& __p, const path& __base = current_path()) {
1854*58b9f456SAndroid Build Coastguard Worker  return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base));
1855*58b9f456SAndroid Build Coastguard Worker}
1856*58b9f456SAndroid Build Coastguard Worker
1857*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) {
1858*58b9f456SAndroid Build Coastguard Worker  return __remove(__p);
1859*58b9f456SAndroid Build Coastguard Worker}
1860*58b9f456SAndroid Build Coastguard Worker
1861*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p,
1862*58b9f456SAndroid Build Coastguard Worker                                             error_code& __ec) noexcept {
1863*58b9f456SAndroid Build Coastguard Worker  return __remove(__p, &__ec);
1864*58b9f456SAndroid Build Coastguard Worker}
1865*58b9f456SAndroid Build Coastguard Worker
1866*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) {
1867*58b9f456SAndroid Build Coastguard Worker  return __remove_all(__p);
1868*58b9f456SAndroid Build Coastguard Worker}
1869*58b9f456SAndroid Build Coastguard Worker
1870*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p,
1871*58b9f456SAndroid Build Coastguard Worker                                                      error_code& __ec) {
1872*58b9f456SAndroid Build Coastguard Worker  return __remove_all(__p, &__ec);
1873*58b9f456SAndroid Build Coastguard Worker}
1874*58b9f456SAndroid Build Coastguard Worker
1875*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from,
1876*58b9f456SAndroid Build Coastguard Worker                                             const path& __to) {
1877*58b9f456SAndroid Build Coastguard Worker  return __rename(__from, __to);
1878*58b9f456SAndroid Build Coastguard Worker}
1879*58b9f456SAndroid Build Coastguard Worker
1880*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1881*58b9f456SAndroid Build Coastguard Workerrename(const path& __from, const path& __to, error_code& __ec) noexcept {
1882*58b9f456SAndroid Build Coastguard Worker  return __rename(__from, __to, &__ec);
1883*58b9f456SAndroid Build Coastguard Worker}
1884*58b9f456SAndroid Build Coastguard Worker
1885*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p,
1886*58b9f456SAndroid Build Coastguard Worker                                                  uintmax_t __ns) {
1887*58b9f456SAndroid Build Coastguard Worker  return __resize_file(__p, __ns);
1888*58b9f456SAndroid Build Coastguard Worker}
1889*58b9f456SAndroid Build Coastguard Worker
1890*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY void
1891*58b9f456SAndroid Build Coastguard Workerresize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept {
1892*58b9f456SAndroid Build Coastguard Worker  return __resize_file(__p, __ns, &__ec);
1893*58b9f456SAndroid Build Coastguard Worker}
1894*58b9f456SAndroid Build Coastguard Worker
1895*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) {
1896*58b9f456SAndroid Build Coastguard Worker  return __space(__p);
1897*58b9f456SAndroid Build Coastguard Worker}
1898*58b9f456SAndroid Build Coastguard Worker
1899*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p,
1900*58b9f456SAndroid Build Coastguard Worker                                                  error_code& __ec) noexcept {
1901*58b9f456SAndroid Build Coastguard Worker  return __space(__p, &__ec);
1902*58b9f456SAndroid Build Coastguard Worker}
1903*58b9f456SAndroid Build Coastguard Worker
1904*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) {
1905*58b9f456SAndroid Build Coastguard Worker  return __status(__p);
1906*58b9f456SAndroid Build Coastguard Worker}
1907*58b9f456SAndroid Build Coastguard Worker
1908*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p,
1909*58b9f456SAndroid Build Coastguard Worker                                                    error_code& __ec) noexcept {
1910*58b9f456SAndroid Build Coastguard Worker  return __status(__p, &__ec);
1911*58b9f456SAndroid Build Coastguard Worker}
1912*58b9f456SAndroid Build Coastguard Worker
1913*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) {
1914*58b9f456SAndroid Build Coastguard Worker  return __symlink_status(__p);
1915*58b9f456SAndroid Build Coastguard Worker}
1916*58b9f456SAndroid Build Coastguard Worker
1917*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY file_status
1918*58b9f456SAndroid Build Coastguard Workersymlink_status(const path& __p, error_code& __ec) noexcept {
1919*58b9f456SAndroid Build Coastguard Worker  return __symlink_status(__p, &__ec);
1920*58b9f456SAndroid Build Coastguard Worker}
1921*58b9f456SAndroid Build Coastguard Worker
1922*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() {
1923*58b9f456SAndroid Build Coastguard Worker  return __temp_directory_path();
1924*58b9f456SAndroid Build Coastguard Worker}
1925*58b9f456SAndroid Build Coastguard Worker
1926*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) {
1927*58b9f456SAndroid Build Coastguard Worker  return __temp_directory_path(&__ec);
1928*58b9f456SAndroid Build Coastguard Worker}
1929*58b9f456SAndroid Build Coastguard Worker
1930*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) {
1931*58b9f456SAndroid Build Coastguard Worker  return __weakly_canonical(__p);
1932*58b9f456SAndroid Build Coastguard Worker}
1933*58b9f456SAndroid Build Coastguard Worker
1934*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p,
1935*58b9f456SAndroid Build Coastguard Worker                                                       error_code& __ec) {
1936*58b9f456SAndroid Build Coastguard Worker  return __weakly_canonical(__p, &__ec);
1937*58b9f456SAndroid Build Coastguard Worker}
1938*58b9f456SAndroid Build Coastguard Worker
1939*58b9f456SAndroid Build Coastguard Workerclass directory_iterator;
1940*58b9f456SAndroid Build Coastguard Workerclass recursive_directory_iterator;
1941*58b9f456SAndroid Build Coastguard Workerclass __dir_stream;
1942*58b9f456SAndroid Build Coastguard Worker
1943*58b9f456SAndroid Build Coastguard Workerclass directory_entry {
1944*58b9f456SAndroid Build Coastguard Worker  typedef _VSTD_FS::path _Path;
1945*58b9f456SAndroid Build Coastguard Worker
1946*58b9f456SAndroid Build Coastguard Workerpublic:
1947*58b9f456SAndroid Build Coastguard Worker  // constructors and destructors
1948*58b9f456SAndroid Build Coastguard Worker  directory_entry() noexcept = default;
1949*58b9f456SAndroid Build Coastguard Worker  directory_entry(directory_entry const&) = default;
1950*58b9f456SAndroid Build Coastguard Worker  directory_entry(directory_entry&&) noexcept = default;
1951*58b9f456SAndroid Build Coastguard Worker
1952*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1953*58b9f456SAndroid Build Coastguard Worker  explicit directory_entry(_Path const& __p) : __p_(__p) {
1954*58b9f456SAndroid Build Coastguard Worker    error_code __ec;
1955*58b9f456SAndroid Build Coastguard Worker    __refresh(&__ec);
1956*58b9f456SAndroid Build Coastguard Worker  }
1957*58b9f456SAndroid Build Coastguard Worker
1958*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1959*58b9f456SAndroid Build Coastguard Worker  directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) {
1960*58b9f456SAndroid Build Coastguard Worker    __refresh(&__ec);
1961*58b9f456SAndroid Build Coastguard Worker  }
1962*58b9f456SAndroid Build Coastguard Worker
1963*58b9f456SAndroid Build Coastguard Worker  ~directory_entry() {}
1964*58b9f456SAndroid Build Coastguard Worker
1965*58b9f456SAndroid Build Coastguard Worker  directory_entry& operator=(directory_entry const&) = default;
1966*58b9f456SAndroid Build Coastguard Worker  directory_entry& operator=(directory_entry&&) noexcept = default;
1967*58b9f456SAndroid Build Coastguard Worker
1968*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1969*58b9f456SAndroid Build Coastguard Worker  void assign(_Path const& __p) {
1970*58b9f456SAndroid Build Coastguard Worker    __p_ = __p;
1971*58b9f456SAndroid Build Coastguard Worker    error_code __ec;
1972*58b9f456SAndroid Build Coastguard Worker    __refresh(&__ec);
1973*58b9f456SAndroid Build Coastguard Worker  }
1974*58b9f456SAndroid Build Coastguard Worker
1975*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1976*58b9f456SAndroid Build Coastguard Worker  void assign(_Path const& __p, error_code& __ec) {
1977*58b9f456SAndroid Build Coastguard Worker    __p_ = __p;
1978*58b9f456SAndroid Build Coastguard Worker    __refresh(&__ec);
1979*58b9f456SAndroid Build Coastguard Worker  }
1980*58b9f456SAndroid Build Coastguard Worker
1981*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1982*58b9f456SAndroid Build Coastguard Worker  void replace_filename(_Path const& __p) {
1983*58b9f456SAndroid Build Coastguard Worker    __p_.replace_filename(__p);
1984*58b9f456SAndroid Build Coastguard Worker    error_code __ec;
1985*58b9f456SAndroid Build Coastguard Worker    __refresh(&__ec);
1986*58b9f456SAndroid Build Coastguard Worker  }
1987*58b9f456SAndroid Build Coastguard Worker
1988*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1989*58b9f456SAndroid Build Coastguard Worker  void replace_filename(_Path const& __p, error_code& __ec) {
1990*58b9f456SAndroid Build Coastguard Worker    __p_ = __p_.parent_path() / __p;
1991*58b9f456SAndroid Build Coastguard Worker    __refresh(&__ec);
1992*58b9f456SAndroid Build Coastguard Worker  }
1993*58b9f456SAndroid Build Coastguard Worker
1994*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1995*58b9f456SAndroid Build Coastguard Worker  void refresh() { __refresh(); }
1996*58b9f456SAndroid Build Coastguard Worker
1997*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
1998*58b9f456SAndroid Build Coastguard Worker  void refresh(error_code& __ec) noexcept { __refresh(&__ec); }
1999*58b9f456SAndroid Build Coastguard Worker
2000*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2001*58b9f456SAndroid Build Coastguard Worker  _Path const& path() const noexcept { return __p_; }
2002*58b9f456SAndroid Build Coastguard Worker
2003*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2004*58b9f456SAndroid Build Coastguard Worker  operator const _Path&() const noexcept { return __p_; }
2005*58b9f456SAndroid Build Coastguard Worker
2006*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2007*58b9f456SAndroid Build Coastguard Worker  bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); }
2008*58b9f456SAndroid Build Coastguard Worker
2009*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2010*58b9f456SAndroid Build Coastguard Worker  bool exists(error_code& __ec) const noexcept {
2011*58b9f456SAndroid Build Coastguard Worker    return _VSTD_FS::exists(file_status{__get_ft(&__ec)});
2012*58b9f456SAndroid Build Coastguard Worker  }
2013*58b9f456SAndroid Build Coastguard Worker
2014*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2015*58b9f456SAndroid Build Coastguard Worker  bool is_block_file() const { return __get_ft() == file_type::block; }
2016*58b9f456SAndroid Build Coastguard Worker
2017*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2018*58b9f456SAndroid Build Coastguard Worker  bool is_block_file(error_code& __ec) const noexcept {
2019*58b9f456SAndroid Build Coastguard Worker    return __get_ft(&__ec) == file_type::block;
2020*58b9f456SAndroid Build Coastguard Worker  }
2021*58b9f456SAndroid Build Coastguard Worker
2022*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2023*58b9f456SAndroid Build Coastguard Worker  bool is_character_file() const { return __get_ft() == file_type::character; }
2024*58b9f456SAndroid Build Coastguard Worker
2025*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2026*58b9f456SAndroid Build Coastguard Worker  bool is_character_file(error_code& __ec) const noexcept {
2027*58b9f456SAndroid Build Coastguard Worker    return __get_ft(&__ec) == file_type::character;
2028*58b9f456SAndroid Build Coastguard Worker  }
2029*58b9f456SAndroid Build Coastguard Worker
2030*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2031*58b9f456SAndroid Build Coastguard Worker  bool is_directory() const { return __get_ft() == file_type::directory; }
2032*58b9f456SAndroid Build Coastguard Worker
2033*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2034*58b9f456SAndroid Build Coastguard Worker  bool is_directory(error_code& __ec) const noexcept {
2035*58b9f456SAndroid Build Coastguard Worker    return __get_ft(&__ec) == file_type::directory;
2036*58b9f456SAndroid Build Coastguard Worker  }
2037*58b9f456SAndroid Build Coastguard Worker
2038*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2039*58b9f456SAndroid Build Coastguard Worker  bool is_fifo() const { return __get_ft() == file_type::fifo; }
2040*58b9f456SAndroid Build Coastguard Worker
2041*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2042*58b9f456SAndroid Build Coastguard Worker  bool is_fifo(error_code& __ec) const noexcept {
2043*58b9f456SAndroid Build Coastguard Worker    return __get_ft(&__ec) == file_type::fifo;
2044*58b9f456SAndroid Build Coastguard Worker  }
2045*58b9f456SAndroid Build Coastguard Worker
2046*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2047*58b9f456SAndroid Build Coastguard Worker  bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); }
2048*58b9f456SAndroid Build Coastguard Worker
2049*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2050*58b9f456SAndroid Build Coastguard Worker  bool is_other(error_code& __ec) const noexcept {
2051*58b9f456SAndroid Build Coastguard Worker    return _VSTD_FS::is_other(file_status{__get_ft(&__ec)});
2052*58b9f456SAndroid Build Coastguard Worker  }
2053*58b9f456SAndroid Build Coastguard Worker
2054*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2055*58b9f456SAndroid Build Coastguard Worker  bool is_regular_file() const { return __get_ft() == file_type::regular; }
2056*58b9f456SAndroid Build Coastguard Worker
2057*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2058*58b9f456SAndroid Build Coastguard Worker  bool is_regular_file(error_code& __ec) const noexcept {
2059*58b9f456SAndroid Build Coastguard Worker    return __get_ft(&__ec) == file_type::regular;
2060*58b9f456SAndroid Build Coastguard Worker  }
2061*58b9f456SAndroid Build Coastguard Worker
2062*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2063*58b9f456SAndroid Build Coastguard Worker  bool is_socket() const { return __get_ft() == file_type::socket; }
2064*58b9f456SAndroid Build Coastguard Worker
2065*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2066*58b9f456SAndroid Build Coastguard Worker  bool is_socket(error_code& __ec) const noexcept {
2067*58b9f456SAndroid Build Coastguard Worker    return __get_ft(&__ec) == file_type::socket;
2068*58b9f456SAndroid Build Coastguard Worker  }
2069*58b9f456SAndroid Build Coastguard Worker
2070*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2071*58b9f456SAndroid Build Coastguard Worker  bool is_symlink() const { return __get_sym_ft() == file_type::symlink; }
2072*58b9f456SAndroid Build Coastguard Worker
2073*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2074*58b9f456SAndroid Build Coastguard Worker  bool is_symlink(error_code& __ec) const noexcept {
2075*58b9f456SAndroid Build Coastguard Worker    return __get_sym_ft(&__ec) == file_type::symlink;
2076*58b9f456SAndroid Build Coastguard Worker  }
2077*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2078*58b9f456SAndroid Build Coastguard Worker  uintmax_t file_size() const { return __get_size(); }
2079*58b9f456SAndroid Build Coastguard Worker
2080*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2081*58b9f456SAndroid Build Coastguard Worker  uintmax_t file_size(error_code& __ec) const noexcept {
2082*58b9f456SAndroid Build Coastguard Worker    return __get_size(&__ec);
2083*58b9f456SAndroid Build Coastguard Worker  }
2084*58b9f456SAndroid Build Coastguard Worker
2085*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2086*58b9f456SAndroid Build Coastguard Worker  uintmax_t hard_link_count() const { return __get_nlink(); }
2087*58b9f456SAndroid Build Coastguard Worker
2088*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2089*58b9f456SAndroid Build Coastguard Worker  uintmax_t hard_link_count(error_code& __ec) const noexcept {
2090*58b9f456SAndroid Build Coastguard Worker    return __get_nlink(&__ec);
2091*58b9f456SAndroid Build Coastguard Worker  }
2092*58b9f456SAndroid Build Coastguard Worker
2093*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2094*58b9f456SAndroid Build Coastguard Worker  file_time_type last_write_time() const { return __get_write_time(); }
2095*58b9f456SAndroid Build Coastguard Worker
2096*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2097*58b9f456SAndroid Build Coastguard Worker  file_time_type last_write_time(error_code& __ec) const noexcept {
2098*58b9f456SAndroid Build Coastguard Worker    return __get_write_time(&__ec);
2099*58b9f456SAndroid Build Coastguard Worker  }
2100*58b9f456SAndroid Build Coastguard Worker
2101*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2102*58b9f456SAndroid Build Coastguard Worker  file_status status() const { return __get_status(); }
2103*58b9f456SAndroid Build Coastguard Worker
2104*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2105*58b9f456SAndroid Build Coastguard Worker  file_status status(error_code& __ec) const noexcept {
2106*58b9f456SAndroid Build Coastguard Worker    return __get_status(&__ec);
2107*58b9f456SAndroid Build Coastguard Worker  }
2108*58b9f456SAndroid Build Coastguard Worker
2109*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2110*58b9f456SAndroid Build Coastguard Worker  file_status symlink_status() const { return __get_symlink_status(); }
2111*58b9f456SAndroid Build Coastguard Worker
2112*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2113*58b9f456SAndroid Build Coastguard Worker  file_status symlink_status(error_code& __ec) const noexcept {
2114*58b9f456SAndroid Build Coastguard Worker    return __get_symlink_status(&__ec);
2115*58b9f456SAndroid Build Coastguard Worker  }
2116*58b9f456SAndroid Build Coastguard Worker
2117*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2118*58b9f456SAndroid Build Coastguard Worker  bool operator<(directory_entry const& __rhs) const noexcept {
2119*58b9f456SAndroid Build Coastguard Worker    return __p_ < __rhs.__p_;
2120*58b9f456SAndroid Build Coastguard Worker  }
2121*58b9f456SAndroid Build Coastguard Worker
2122*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2123*58b9f456SAndroid Build Coastguard Worker  bool operator==(directory_entry const& __rhs) const noexcept {
2124*58b9f456SAndroid Build Coastguard Worker    return __p_ == __rhs.__p_;
2125*58b9f456SAndroid Build Coastguard Worker  }
2126*58b9f456SAndroid Build Coastguard Worker
2127*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2128*58b9f456SAndroid Build Coastguard Worker  bool operator!=(directory_entry const& __rhs) const noexcept {
2129*58b9f456SAndroid Build Coastguard Worker    return __p_ != __rhs.__p_;
2130*58b9f456SAndroid Build Coastguard Worker  }
2131*58b9f456SAndroid Build Coastguard Worker
2132*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2133*58b9f456SAndroid Build Coastguard Worker  bool operator<=(directory_entry const& __rhs) const noexcept {
2134*58b9f456SAndroid Build Coastguard Worker    return __p_ <= __rhs.__p_;
2135*58b9f456SAndroid Build Coastguard Worker  }
2136*58b9f456SAndroid Build Coastguard Worker
2137*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2138*58b9f456SAndroid Build Coastguard Worker  bool operator>(directory_entry const& __rhs) const noexcept {
2139*58b9f456SAndroid Build Coastguard Worker    return __p_ > __rhs.__p_;
2140*58b9f456SAndroid Build Coastguard Worker  }
2141*58b9f456SAndroid Build Coastguard Worker
2142*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2143*58b9f456SAndroid Build Coastguard Worker  bool operator>=(directory_entry const& __rhs) const noexcept {
2144*58b9f456SAndroid Build Coastguard Worker    return __p_ >= __rhs.__p_;
2145*58b9f456SAndroid Build Coastguard Worker  }
2146*58b9f456SAndroid Build Coastguard Worker
2147*58b9f456SAndroid Build Coastguard Workerprivate:
2148*58b9f456SAndroid Build Coastguard Worker  friend class directory_iterator;
2149*58b9f456SAndroid Build Coastguard Worker  friend class recursive_directory_iterator;
2150*58b9f456SAndroid Build Coastguard Worker  friend class __dir_stream;
2151*58b9f456SAndroid Build Coastguard Worker
2152*58b9f456SAndroid Build Coastguard Worker  enum _CacheType : unsigned char {
2153*58b9f456SAndroid Build Coastguard Worker    _Empty,
2154*58b9f456SAndroid Build Coastguard Worker    _IterSymlink,
2155*58b9f456SAndroid Build Coastguard Worker    _IterNonSymlink,
2156*58b9f456SAndroid Build Coastguard Worker    _RefreshSymlink,
2157*58b9f456SAndroid Build Coastguard Worker    _RefreshSymlinkUnresolved,
2158*58b9f456SAndroid Build Coastguard Worker    _RefreshNonSymlink
2159*58b9f456SAndroid Build Coastguard Worker  };
2160*58b9f456SAndroid Build Coastguard Worker
2161*58b9f456SAndroid Build Coastguard Worker  struct __cached_data {
2162*58b9f456SAndroid Build Coastguard Worker    uintmax_t __size_;
2163*58b9f456SAndroid Build Coastguard Worker    uintmax_t __nlink_;
2164*58b9f456SAndroid Build Coastguard Worker    file_time_type __write_time_;
2165*58b9f456SAndroid Build Coastguard Worker    perms __sym_perms_;
2166*58b9f456SAndroid Build Coastguard Worker    perms __non_sym_perms_;
2167*58b9f456SAndroid Build Coastguard Worker    file_type __type_;
2168*58b9f456SAndroid Build Coastguard Worker    _CacheType __cache_type_;
2169*58b9f456SAndroid Build Coastguard Worker
2170*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
2171*58b9f456SAndroid Build Coastguard Worker    __cached_data() noexcept { __reset(); }
2172*58b9f456SAndroid Build Coastguard Worker
2173*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
2174*58b9f456SAndroid Build Coastguard Worker    void __reset() {
2175*58b9f456SAndroid Build Coastguard Worker      __cache_type_ = _Empty;
2176*58b9f456SAndroid Build Coastguard Worker      __type_ = file_type::none;
2177*58b9f456SAndroid Build Coastguard Worker      __sym_perms_ = __non_sym_perms_ = perms::unknown;
2178*58b9f456SAndroid Build Coastguard Worker      __size_ = __nlink_ = uintmax_t(-1);
2179*58b9f456SAndroid Build Coastguard Worker      __write_time_ = file_time_type::min();
2180*58b9f456SAndroid Build Coastguard Worker    }
2181*58b9f456SAndroid Build Coastguard Worker  };
2182*58b9f456SAndroid Build Coastguard Worker
2183*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2184*58b9f456SAndroid Build Coastguard Worker  static __cached_data __create_iter_result(file_type __ft) {
2185*58b9f456SAndroid Build Coastguard Worker    __cached_data __data;
2186*58b9f456SAndroid Build Coastguard Worker    __data.__type_ = __ft;
2187*58b9f456SAndroid Build Coastguard Worker    __data.__cache_type_ = [&]() {
2188*58b9f456SAndroid Build Coastguard Worker      switch (__ft) {
2189*58b9f456SAndroid Build Coastguard Worker      case file_type::none:
2190*58b9f456SAndroid Build Coastguard Worker        return _Empty;
2191*58b9f456SAndroid Build Coastguard Worker      case file_type::symlink:
2192*58b9f456SAndroid Build Coastguard Worker        return _IterSymlink;
2193*58b9f456SAndroid Build Coastguard Worker      default:
2194*58b9f456SAndroid Build Coastguard Worker        return _IterNonSymlink;
2195*58b9f456SAndroid Build Coastguard Worker      }
2196*58b9f456SAndroid Build Coastguard Worker    }();
2197*58b9f456SAndroid Build Coastguard Worker    return __data;
2198*58b9f456SAndroid Build Coastguard Worker  }
2199*58b9f456SAndroid Build Coastguard Worker
2200*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2201*58b9f456SAndroid Build Coastguard Worker  void __assign_iter_entry(_Path&& __p, __cached_data __dt) {
2202*58b9f456SAndroid Build Coastguard Worker    __p_ = std::move(__p);
2203*58b9f456SAndroid Build Coastguard Worker    __data_ = __dt;
2204*58b9f456SAndroid Build Coastguard Worker  }
2205*58b9f456SAndroid Build Coastguard Worker
2206*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2207*58b9f456SAndroid Build Coastguard Worker  error_code __do_refresh() noexcept;
2208*58b9f456SAndroid Build Coastguard Worker
2209*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2210*58b9f456SAndroid Build Coastguard Worker  static bool __is_dne_error(error_code const& __ec) {
2211*58b9f456SAndroid Build Coastguard Worker    if (!__ec)
2212*58b9f456SAndroid Build Coastguard Worker      return true;
2213*58b9f456SAndroid Build Coastguard Worker    switch (static_cast<errc>(__ec.value())) {
2214*58b9f456SAndroid Build Coastguard Worker    case errc::no_such_file_or_directory:
2215*58b9f456SAndroid Build Coastguard Worker    case errc::not_a_directory:
2216*58b9f456SAndroid Build Coastguard Worker      return true;
2217*58b9f456SAndroid Build Coastguard Worker    default:
2218*58b9f456SAndroid Build Coastguard Worker      return false;
2219*58b9f456SAndroid Build Coastguard Worker    }
2220*58b9f456SAndroid Build Coastguard Worker  }
2221*58b9f456SAndroid Build Coastguard Worker
2222*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2223*58b9f456SAndroid Build Coastguard Worker  void __handle_error(const char* __msg, error_code* __dest_ec,
2224*58b9f456SAndroid Build Coastguard Worker                      error_code const& __ec, bool __allow_dne = false) const {
2225*58b9f456SAndroid Build Coastguard Worker    if (__dest_ec) {
2226*58b9f456SAndroid Build Coastguard Worker      *__dest_ec = __ec;
2227*58b9f456SAndroid Build Coastguard Worker      return;
2228*58b9f456SAndroid Build Coastguard Worker    }
2229*58b9f456SAndroid Build Coastguard Worker    if (__ec && (!__allow_dne || !__is_dne_error(__ec)))
2230*58b9f456SAndroid Build Coastguard Worker      __throw_filesystem_error(__msg, __p_, __ec);
2231*58b9f456SAndroid Build Coastguard Worker  }
2232*58b9f456SAndroid Build Coastguard Worker
2233*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2234*58b9f456SAndroid Build Coastguard Worker  void __refresh(error_code* __ec = nullptr) {
2235*58b9f456SAndroid Build Coastguard Worker    __handle_error("in directory_entry::refresh", __ec, __do_refresh(),
2236*58b9f456SAndroid Build Coastguard Worker                   /*allow_dne*/ true);
2237*58b9f456SAndroid Build Coastguard Worker  }
2238*58b9f456SAndroid Build Coastguard Worker
2239*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2240*58b9f456SAndroid Build Coastguard Worker  file_type __get_sym_ft(error_code* __ec = nullptr) const {
2241*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2242*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2243*58b9f456SAndroid Build Coastguard Worker      return __symlink_status(__p_, __ec).type();
2244*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2245*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink:
2246*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2247*58b9f456SAndroid Build Coastguard Worker      if (__ec)
2248*58b9f456SAndroid Build Coastguard Worker        __ec->clear();
2249*58b9f456SAndroid Build Coastguard Worker      return file_type::symlink;
2250*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2251*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink:
2252*58b9f456SAndroid Build Coastguard Worker      file_status __st(__data_.__type_);
2253*58b9f456SAndroid Build Coastguard Worker      if (__ec && !_VSTD_FS::exists(__st))
2254*58b9f456SAndroid Build Coastguard Worker        *__ec = make_error_code(errc::no_such_file_or_directory);
2255*58b9f456SAndroid Build Coastguard Worker      else if (__ec)
2256*58b9f456SAndroid Build Coastguard Worker        __ec->clear();
2257*58b9f456SAndroid Build Coastguard Worker      return __data_.__type_;
2258*58b9f456SAndroid Build Coastguard Worker    }
2259*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2260*58b9f456SAndroid Build Coastguard Worker  }
2261*58b9f456SAndroid Build Coastguard Worker
2262*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2263*58b9f456SAndroid Build Coastguard Worker  file_type __get_ft(error_code* __ec = nullptr) const {
2264*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2265*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2266*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2267*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2268*58b9f456SAndroid Build Coastguard Worker      return __status(__p_, __ec).type();
2269*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2270*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink:
2271*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink: {
2272*58b9f456SAndroid Build Coastguard Worker      file_status __st(__data_.__type_);
2273*58b9f456SAndroid Build Coastguard Worker      if (__ec && !_VSTD_FS::exists(__st))
2274*58b9f456SAndroid Build Coastguard Worker        *__ec = make_error_code(errc::no_such_file_or_directory);
2275*58b9f456SAndroid Build Coastguard Worker      else if (__ec)
2276*58b9f456SAndroid Build Coastguard Worker        __ec->clear();
2277*58b9f456SAndroid Build Coastguard Worker      return __data_.__type_;
2278*58b9f456SAndroid Build Coastguard Worker    }
2279*58b9f456SAndroid Build Coastguard Worker    }
2280*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2281*58b9f456SAndroid Build Coastguard Worker  }
2282*58b9f456SAndroid Build Coastguard Worker
2283*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2284*58b9f456SAndroid Build Coastguard Worker  file_status __get_status(error_code* __ec = nullptr) const {
2285*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2286*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2287*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2288*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2289*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2290*58b9f456SAndroid Build Coastguard Worker      return __status(__p_, __ec);
2291*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink:
2292*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink:
2293*58b9f456SAndroid Build Coastguard Worker      return file_status(__get_ft(__ec), __data_.__non_sym_perms_);
2294*58b9f456SAndroid Build Coastguard Worker    }
2295*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2296*58b9f456SAndroid Build Coastguard Worker  }
2297*58b9f456SAndroid Build Coastguard Worker
2298*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2299*58b9f456SAndroid Build Coastguard Worker  file_status __get_symlink_status(error_code* __ec = nullptr) const {
2300*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2301*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2302*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2303*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2304*58b9f456SAndroid Build Coastguard Worker      return __symlink_status(__p_, __ec);
2305*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink:
2306*58b9f456SAndroid Build Coastguard Worker      return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_);
2307*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink:
2308*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2309*58b9f456SAndroid Build Coastguard Worker      return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);
2310*58b9f456SAndroid Build Coastguard Worker    }
2311*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2312*58b9f456SAndroid Build Coastguard Worker  }
2313*58b9f456SAndroid Build Coastguard Worker
2314*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2315*58b9f456SAndroid Build Coastguard Worker  uintmax_t __get_size(error_code* __ec = nullptr) const {
2316*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2317*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2318*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2319*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2320*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2321*58b9f456SAndroid Build Coastguard Worker      return _VSTD_FS::__file_size(__p_, __ec);
2322*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink:
2323*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink: {
2324*58b9f456SAndroid Build Coastguard Worker      error_code __m_ec;
2325*58b9f456SAndroid Build Coastguard Worker      file_status __st(__get_ft(&__m_ec));
2326*58b9f456SAndroid Build Coastguard Worker      __handle_error("in directory_entry::file_size", __ec, __m_ec);
2327*58b9f456SAndroid Build Coastguard Worker      if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) {
2328*58b9f456SAndroid Build Coastguard Worker        errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory
2329*58b9f456SAndroid Build Coastguard Worker                                                       : errc::not_supported;
2330*58b9f456SAndroid Build Coastguard Worker        __handle_error("in directory_entry::file_size", __ec,
2331*58b9f456SAndroid Build Coastguard Worker                       make_error_code(__err_kind));
2332*58b9f456SAndroid Build Coastguard Worker      }
2333*58b9f456SAndroid Build Coastguard Worker      return __data_.__size_;
2334*58b9f456SAndroid Build Coastguard Worker    }
2335*58b9f456SAndroid Build Coastguard Worker    }
2336*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2337*58b9f456SAndroid Build Coastguard Worker  }
2338*58b9f456SAndroid Build Coastguard Worker
2339*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2340*58b9f456SAndroid Build Coastguard Worker  uintmax_t __get_nlink(error_code* __ec = nullptr) const {
2341*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2342*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2343*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2344*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2345*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2346*58b9f456SAndroid Build Coastguard Worker      return _VSTD_FS::__hard_link_count(__p_, __ec);
2347*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink:
2348*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink: {
2349*58b9f456SAndroid Build Coastguard Worker      error_code __m_ec;
2350*58b9f456SAndroid Build Coastguard Worker      (void)__get_ft(&__m_ec);
2351*58b9f456SAndroid Build Coastguard Worker      __handle_error("in directory_entry::hard_link_count", __ec, __m_ec);
2352*58b9f456SAndroid Build Coastguard Worker      return __data_.__nlink_;
2353*58b9f456SAndroid Build Coastguard Worker    }
2354*58b9f456SAndroid Build Coastguard Worker    }
2355*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2356*58b9f456SAndroid Build Coastguard Worker  }
2357*58b9f456SAndroid Build Coastguard Worker
2358*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2359*58b9f456SAndroid Build Coastguard Worker  file_time_type __get_write_time(error_code* __ec = nullptr) const {
2360*58b9f456SAndroid Build Coastguard Worker    switch (__data_.__cache_type_) {
2361*58b9f456SAndroid Build Coastguard Worker    case _Empty:
2362*58b9f456SAndroid Build Coastguard Worker    case _IterNonSymlink:
2363*58b9f456SAndroid Build Coastguard Worker    case _IterSymlink:
2364*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlinkUnresolved:
2365*58b9f456SAndroid Build Coastguard Worker      return _VSTD_FS::__last_write_time(__p_, __ec);
2366*58b9f456SAndroid Build Coastguard Worker    case _RefreshSymlink:
2367*58b9f456SAndroid Build Coastguard Worker    case _RefreshNonSymlink: {
2368*58b9f456SAndroid Build Coastguard Worker      error_code __m_ec;
2369*58b9f456SAndroid Build Coastguard Worker      file_status __st(__get_ft(&__m_ec));
2370*58b9f456SAndroid Build Coastguard Worker      __handle_error("in directory_entry::last_write_time", __ec, __m_ec);
2371*58b9f456SAndroid Build Coastguard Worker      if (_VSTD_FS::exists(__st) &&
2372*58b9f456SAndroid Build Coastguard Worker          __data_.__write_time_ == file_time_type::min())
2373*58b9f456SAndroid Build Coastguard Worker        __handle_error("in directory_entry::last_write_time", __ec,
2374*58b9f456SAndroid Build Coastguard Worker                       make_error_code(errc::value_too_large));
2375*58b9f456SAndroid Build Coastguard Worker      return __data_.__write_time_;
2376*58b9f456SAndroid Build Coastguard Worker    }
2377*58b9f456SAndroid Build Coastguard Worker    }
2378*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_UNREACHABLE();
2379*58b9f456SAndroid Build Coastguard Worker  }
2380*58b9f456SAndroid Build Coastguard Worker
2381*58b9f456SAndroid Build Coastguard Workerprivate:
2382*58b9f456SAndroid Build Coastguard Worker  _Path __p_;
2383*58b9f456SAndroid Build Coastguard Worker  __cached_data __data_;
2384*58b9f456SAndroid Build Coastguard Worker};
2385*58b9f456SAndroid Build Coastguard Worker
2386*58b9f456SAndroid Build Coastguard Workerclass __dir_element_proxy {
2387*58b9f456SAndroid Build Coastguard Workerpublic:
2388*58b9f456SAndroid Build Coastguard Worker  inline _LIBCPP_INLINE_VISIBILITY directory_entry operator*() {
2389*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__elem_);
2390*58b9f456SAndroid Build Coastguard Worker  }
2391*58b9f456SAndroid Build Coastguard Worker
2392*58b9f456SAndroid Build Coastguard Workerprivate:
2393*58b9f456SAndroid Build Coastguard Worker  friend class directory_iterator;
2394*58b9f456SAndroid Build Coastguard Worker  friend class recursive_directory_iterator;
2395*58b9f456SAndroid Build Coastguard Worker  explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {}
2396*58b9f456SAndroid Build Coastguard Worker  __dir_element_proxy(__dir_element_proxy&& __o)
2397*58b9f456SAndroid Build Coastguard Worker      : __elem_(_VSTD::move(__o.__elem_)) {}
2398*58b9f456SAndroid Build Coastguard Worker  directory_entry __elem_;
2399*58b9f456SAndroid Build Coastguard Worker};
2400*58b9f456SAndroid Build Coastguard Worker
2401*58b9f456SAndroid Build Coastguard Workerclass directory_iterator {
2402*58b9f456SAndroid Build Coastguard Workerpublic:
2403*58b9f456SAndroid Build Coastguard Worker  typedef directory_entry value_type;
2404*58b9f456SAndroid Build Coastguard Worker  typedef ptrdiff_t difference_type;
2405*58b9f456SAndroid Build Coastguard Worker  typedef value_type const* pointer;
2406*58b9f456SAndroid Build Coastguard Worker  typedef value_type const& reference;
2407*58b9f456SAndroid Build Coastguard Worker  typedef input_iterator_tag iterator_category;
2408*58b9f456SAndroid Build Coastguard Worker
2409*58b9f456SAndroid Build Coastguard Workerpublic:
2410*58b9f456SAndroid Build Coastguard Worker  //ctor & dtor
2411*58b9f456SAndroid Build Coastguard Worker  directory_iterator() noexcept {}
2412*58b9f456SAndroid Build Coastguard Worker
2413*58b9f456SAndroid Build Coastguard Worker  explicit directory_iterator(const path& __p)
2414*58b9f456SAndroid Build Coastguard Worker      : directory_iterator(__p, nullptr) {}
2415*58b9f456SAndroid Build Coastguard Worker
2416*58b9f456SAndroid Build Coastguard Worker  directory_iterator(const path& __p, directory_options __opts)
2417*58b9f456SAndroid Build Coastguard Worker      : directory_iterator(__p, nullptr, __opts) {}
2418*58b9f456SAndroid Build Coastguard Worker
2419*58b9f456SAndroid Build Coastguard Worker  directory_iterator(const path& __p, error_code& __ec)
2420*58b9f456SAndroid Build Coastguard Worker      : directory_iterator(__p, &__ec) {}
2421*58b9f456SAndroid Build Coastguard Worker
2422*58b9f456SAndroid Build Coastguard Worker  directory_iterator(const path& __p, directory_options __opts,
2423*58b9f456SAndroid Build Coastguard Worker                     error_code& __ec)
2424*58b9f456SAndroid Build Coastguard Worker      : directory_iterator(__p, &__ec, __opts) {}
2425*58b9f456SAndroid Build Coastguard Worker
2426*58b9f456SAndroid Build Coastguard Worker  directory_iterator(const directory_iterator&) = default;
2427*58b9f456SAndroid Build Coastguard Worker  directory_iterator(directory_iterator&&) = default;
2428*58b9f456SAndroid Build Coastguard Worker  directory_iterator& operator=(const directory_iterator&) = default;
2429*58b9f456SAndroid Build Coastguard Worker
2430*58b9f456SAndroid Build Coastguard Worker  directory_iterator& operator=(directory_iterator&& __o) noexcept {
2431*58b9f456SAndroid Build Coastguard Worker    // non-default implementation provided to support self-move assign.
2432*58b9f456SAndroid Build Coastguard Worker    if (this != &__o) {
2433*58b9f456SAndroid Build Coastguard Worker      __imp_ = _VSTD::move(__o.__imp_);
2434*58b9f456SAndroid Build Coastguard Worker    }
2435*58b9f456SAndroid Build Coastguard Worker    return *this;
2436*58b9f456SAndroid Build Coastguard Worker  }
2437*58b9f456SAndroid Build Coastguard Worker
2438*58b9f456SAndroid Build Coastguard Worker  ~directory_iterator() = default;
2439*58b9f456SAndroid Build Coastguard Worker
2440*58b9f456SAndroid Build Coastguard Worker  const directory_entry& operator*() const {
2441*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");
2442*58b9f456SAndroid Build Coastguard Worker    return __dereference();
2443*58b9f456SAndroid Build Coastguard Worker  }
2444*58b9f456SAndroid Build Coastguard Worker
2445*58b9f456SAndroid Build Coastguard Worker  const directory_entry* operator->() const { return &**this; }
2446*58b9f456SAndroid Build Coastguard Worker
2447*58b9f456SAndroid Build Coastguard Worker  directory_iterator& operator++() { return __increment(); }
2448*58b9f456SAndroid Build Coastguard Worker
2449*58b9f456SAndroid Build Coastguard Worker  __dir_element_proxy operator++(int) {
2450*58b9f456SAndroid Build Coastguard Worker    __dir_element_proxy __p(**this);
2451*58b9f456SAndroid Build Coastguard Worker    __increment();
2452*58b9f456SAndroid Build Coastguard Worker    return __p;
2453*58b9f456SAndroid Build Coastguard Worker  }
2454*58b9f456SAndroid Build Coastguard Worker
2455*58b9f456SAndroid Build Coastguard Worker  directory_iterator& increment(error_code& __ec) { return __increment(&__ec); }
2456*58b9f456SAndroid Build Coastguard Worker
2457*58b9f456SAndroid Build Coastguard Workerprivate:
2458*58b9f456SAndroid Build Coastguard Worker  inline _LIBCPP_INLINE_VISIBILITY friend bool
2459*58b9f456SAndroid Build Coastguard Worker  operator==(const directory_iterator& __lhs,
2460*58b9f456SAndroid Build Coastguard Worker             const directory_iterator& __rhs) noexcept;
2461*58b9f456SAndroid Build Coastguard Worker
2462*58b9f456SAndroid Build Coastguard Worker  // construct the dir_stream
2463*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2464*58b9f456SAndroid Build Coastguard Worker  directory_iterator(const path&, error_code*,
2465*58b9f456SAndroid Build Coastguard Worker                     directory_options = directory_options::none);
2466*58b9f456SAndroid Build Coastguard Worker
2467*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2468*58b9f456SAndroid Build Coastguard Worker  directory_iterator& __increment(error_code* __ec = nullptr);
2469*58b9f456SAndroid Build Coastguard Worker
2470*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2471*58b9f456SAndroid Build Coastguard Worker  const directory_entry& __dereference() const;
2472*58b9f456SAndroid Build Coastguard Worker
2473*58b9f456SAndroid Build Coastguard Workerprivate:
2474*58b9f456SAndroid Build Coastguard Worker  shared_ptr<__dir_stream> __imp_;
2475*58b9f456SAndroid Build Coastguard Worker};
2476*58b9f456SAndroid Build Coastguard Worker
2477*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
2478*58b9f456SAndroid Build Coastguard Workeroperator==(const directory_iterator& __lhs,
2479*58b9f456SAndroid Build Coastguard Worker           const directory_iterator& __rhs) noexcept {
2480*58b9f456SAndroid Build Coastguard Worker  return __lhs.__imp_ == __rhs.__imp_;
2481*58b9f456SAndroid Build Coastguard Worker}
2482*58b9f456SAndroid Build Coastguard Worker
2483*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
2484*58b9f456SAndroid Build Coastguard Workeroperator!=(const directory_iterator& __lhs,
2485*58b9f456SAndroid Build Coastguard Worker           const directory_iterator& __rhs) noexcept {
2486*58b9f456SAndroid Build Coastguard Worker  return !(__lhs == __rhs);
2487*58b9f456SAndroid Build Coastguard Worker}
2488*58b9f456SAndroid Build Coastguard Worker
2489*58b9f456SAndroid Build Coastguard Worker// enable directory_iterator range-based for statements
2490*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY directory_iterator
2491*58b9f456SAndroid Build Coastguard Workerbegin(directory_iterator __iter) noexcept {
2492*58b9f456SAndroid Build Coastguard Worker  return __iter;
2493*58b9f456SAndroid Build Coastguard Worker}
2494*58b9f456SAndroid Build Coastguard Worker
2495*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY directory_iterator
2496*58b9f456SAndroid Build Coastguard Workerend(const directory_iterator&) noexcept {
2497*58b9f456SAndroid Build Coastguard Worker  return directory_iterator();
2498*58b9f456SAndroid Build Coastguard Worker}
2499*58b9f456SAndroid Build Coastguard Worker
2500*58b9f456SAndroid Build Coastguard Workerclass recursive_directory_iterator {
2501*58b9f456SAndroid Build Coastguard Workerpublic:
2502*58b9f456SAndroid Build Coastguard Worker  using value_type = directory_entry;
2503*58b9f456SAndroid Build Coastguard Worker  using difference_type = std::ptrdiff_t;
2504*58b9f456SAndroid Build Coastguard Worker  using pointer = directory_entry const*;
2505*58b9f456SAndroid Build Coastguard Worker  using reference = directory_entry const&;
2506*58b9f456SAndroid Build Coastguard Worker  using iterator_category = std::input_iterator_tag;
2507*58b9f456SAndroid Build Coastguard Worker
2508*58b9f456SAndroid Build Coastguard Workerpublic:
2509*58b9f456SAndroid Build Coastguard Worker  // constructors and destructor
2510*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2511*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator() noexcept : __rec_(false) {}
2512*58b9f456SAndroid Build Coastguard Worker
2513*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2514*58b9f456SAndroid Build Coastguard Worker  explicit recursive_directory_iterator(
2515*58b9f456SAndroid Build Coastguard Worker      const path& __p, directory_options __xoptions = directory_options::none)
2516*58b9f456SAndroid Build Coastguard Worker      : recursive_directory_iterator(__p, __xoptions, nullptr) {}
2517*58b9f456SAndroid Build Coastguard Worker
2518*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2519*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator(const path& __p, directory_options __xoptions,
2520*58b9f456SAndroid Build Coastguard Worker                               error_code& __ec)
2521*58b9f456SAndroid Build Coastguard Worker      : recursive_directory_iterator(__p, __xoptions, &__ec) {}
2522*58b9f456SAndroid Build Coastguard Worker
2523*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2524*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator(const path& __p, error_code& __ec)
2525*58b9f456SAndroid Build Coastguard Worker      : recursive_directory_iterator(__p, directory_options::none, &__ec) {}
2526*58b9f456SAndroid Build Coastguard Worker
2527*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator(const recursive_directory_iterator&) = default;
2528*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator(recursive_directory_iterator&&) = default;
2529*58b9f456SAndroid Build Coastguard Worker
2530*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator&
2531*58b9f456SAndroid Build Coastguard Worker  operator=(const recursive_directory_iterator&) = default;
2532*58b9f456SAndroid Build Coastguard Worker
2533*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2534*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator&
2535*58b9f456SAndroid Build Coastguard Worker  operator=(recursive_directory_iterator&& __o) noexcept {
2536*58b9f456SAndroid Build Coastguard Worker    // non-default implementation provided to support self-move assign.
2537*58b9f456SAndroid Build Coastguard Worker    if (this != &__o) {
2538*58b9f456SAndroid Build Coastguard Worker      __imp_ = _VSTD::move(__o.__imp_);
2539*58b9f456SAndroid Build Coastguard Worker      __rec_ = __o.__rec_;
2540*58b9f456SAndroid Build Coastguard Worker    }
2541*58b9f456SAndroid Build Coastguard Worker    return *this;
2542*58b9f456SAndroid Build Coastguard Worker  }
2543*58b9f456SAndroid Build Coastguard Worker
2544*58b9f456SAndroid Build Coastguard Worker  ~recursive_directory_iterator() = default;
2545*58b9f456SAndroid Build Coastguard Worker
2546*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2547*58b9f456SAndroid Build Coastguard Worker  const directory_entry& operator*() const { return __dereference(); }
2548*58b9f456SAndroid Build Coastguard Worker
2549*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2550*58b9f456SAndroid Build Coastguard Worker  const directory_entry* operator->() const { return &__dereference(); }
2551*58b9f456SAndroid Build Coastguard Worker
2552*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator& operator++() { return __increment(); }
2553*58b9f456SAndroid Build Coastguard Worker
2554*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2555*58b9f456SAndroid Build Coastguard Worker  __dir_element_proxy operator++(int) {
2556*58b9f456SAndroid Build Coastguard Worker    __dir_element_proxy __p(**this);
2557*58b9f456SAndroid Build Coastguard Worker    __increment();
2558*58b9f456SAndroid Build Coastguard Worker    return __p;
2559*58b9f456SAndroid Build Coastguard Worker  }
2560*58b9f456SAndroid Build Coastguard Worker
2561*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2562*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator& increment(error_code& __ec) {
2563*58b9f456SAndroid Build Coastguard Worker    return __increment(&__ec);
2564*58b9f456SAndroid Build Coastguard Worker  }
2565*58b9f456SAndroid Build Coastguard Worker
2566*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS directory_options options() const;
2567*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS int depth() const;
2568*58b9f456SAndroid Build Coastguard Worker
2569*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2570*58b9f456SAndroid Build Coastguard Worker  void pop() { __pop(); }
2571*58b9f456SAndroid Build Coastguard Worker
2572*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2573*58b9f456SAndroid Build Coastguard Worker  void pop(error_code& __ec) { __pop(&__ec); }
2574*58b9f456SAndroid Build Coastguard Worker
2575*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2576*58b9f456SAndroid Build Coastguard Worker  bool recursion_pending() const { return __rec_; }
2577*58b9f456SAndroid Build Coastguard Worker
2578*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
2579*58b9f456SAndroid Build Coastguard Worker  void disable_recursion_pending() { __rec_ = false; }
2580*58b9f456SAndroid Build Coastguard Worker
2581*58b9f456SAndroid Build Coastguard Workerprivate:
2582*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator(const path& __p, directory_options __opt,
2583*58b9f456SAndroid Build Coastguard Worker                               error_code* __ec);
2584*58b9f456SAndroid Build Coastguard Worker
2585*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2586*58b9f456SAndroid Build Coastguard Worker  const directory_entry& __dereference() const;
2587*58b9f456SAndroid Build Coastguard Worker
2588*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2589*58b9f456SAndroid Build Coastguard Worker  bool __try_recursion(error_code* __ec);
2590*58b9f456SAndroid Build Coastguard Worker
2591*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2592*58b9f456SAndroid Build Coastguard Worker  void __advance(error_code* __ec = nullptr);
2593*58b9f456SAndroid Build Coastguard Worker
2594*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2595*58b9f456SAndroid Build Coastguard Worker  recursive_directory_iterator& __increment(error_code* __ec = nullptr);
2596*58b9f456SAndroid Build Coastguard Worker
2597*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_FUNC_VIS
2598*58b9f456SAndroid Build Coastguard Worker  void __pop(error_code* __ec = nullptr);
2599*58b9f456SAndroid Build Coastguard Worker
2600*58b9f456SAndroid Build Coastguard Worker  inline _LIBCPP_INLINE_VISIBILITY friend bool
2601*58b9f456SAndroid Build Coastguard Worker  operator==(const recursive_directory_iterator&,
2602*58b9f456SAndroid Build Coastguard Worker             const recursive_directory_iterator&) noexcept;
2603*58b9f456SAndroid Build Coastguard Worker
2604*58b9f456SAndroid Build Coastguard Worker  struct __shared_imp;
2605*58b9f456SAndroid Build Coastguard Worker  shared_ptr<__shared_imp> __imp_;
2606*58b9f456SAndroid Build Coastguard Worker  bool __rec_;
2607*58b9f456SAndroid Build Coastguard Worker}; // class recursive_directory_iterator
2608*58b9f456SAndroid Build Coastguard Worker
2609*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY bool
2610*58b9f456SAndroid Build Coastguard Workeroperator==(const recursive_directory_iterator& __lhs,
2611*58b9f456SAndroid Build Coastguard Worker           const recursive_directory_iterator& __rhs) noexcept {
2612*58b9f456SAndroid Build Coastguard Worker  return __lhs.__imp_ == __rhs.__imp_;
2613*58b9f456SAndroid Build Coastguard Worker}
2614*58b9f456SAndroid Build Coastguard Worker
2615*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2616*58b9f456SAndroid Build Coastguard Workerinline bool operator!=(const recursive_directory_iterator& __lhs,
2617*58b9f456SAndroid Build Coastguard Worker                       const recursive_directory_iterator& __rhs) noexcept {
2618*58b9f456SAndroid Build Coastguard Worker  return !(__lhs == __rhs);
2619*58b9f456SAndroid Build Coastguard Worker}
2620*58b9f456SAndroid Build Coastguard Worker// enable recursive_directory_iterator range-based for statements
2621*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator
2622*58b9f456SAndroid Build Coastguard Workerbegin(recursive_directory_iterator __iter) noexcept {
2623*58b9f456SAndroid Build Coastguard Worker  return __iter;
2624*58b9f456SAndroid Build Coastguard Worker}
2625*58b9f456SAndroid Build Coastguard Worker
2626*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator
2627*58b9f456SAndroid Build Coastguard Workerend(const recursive_directory_iterator&) noexcept {
2628*58b9f456SAndroid Build Coastguard Worker  return recursive_directory_iterator();
2629*58b9f456SAndroid Build Coastguard Worker}
2630*58b9f456SAndroid Build Coastguard Worker
2631*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_FILESYSTEM
2632*58b9f456SAndroid Build Coastguard Worker
2633*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG
2634*58b9f456SAndroid Build Coastguard Worker
2635*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
2636*58b9f456SAndroid Build Coastguard Worker
2637*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_FILESYSTEM
2638