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