blob: 28d8dcf4fc13c8822dee65e49bc3b2e130bc834f [file] [log] [blame]
Eric Fiselier435db152016-06-17 19:46:40 +00001// -*- C++ -*-
2//===--------------------------- filesystem -------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10#ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM
11#define _LIBCPP_EXPERIMENTAL_FILESYSTEM
12/*
13 filesystem synopsis
14
15 namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
16
17 class path;
18
Eric Fiselierd7c4ec82018-07-25 03:41:31 +000019 void swap(path& lhs, path& rhs) noexcept;
20 size_t hash_value(const path& p) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +000021
Eric Fiselierd7c4ec82018-07-25 03:41:31 +000022 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 bool operator>=(const path& lhs, const path& rhs) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +000028
29 path operator/ (const path& lhs, const path& rhs);
30
Eric Fiselier2cd75272018-02-04 03:10:53 +000031 // fs.path.io operators are friends of path.
Eric Fiselier435db152016-06-17 19:46:40 +000032 template <class charT, class traits>
Eric Fiselier2cd75272018-02-04 03:10:53 +000033 friend basic_ostream<charT, traits>&
Eric Fiselier435db152016-06-17 19:46:40 +000034 operator<<(basic_ostream<charT, traits>& os, const path& p);
35
36 template <class charT, class traits>
Eric Fiselier2cd75272018-02-04 03:10:53 +000037 friend basic_istream<charT, traits>&
Eric Fiselier435db152016-06-17 19:46:40 +000038 operator>>(basic_istream<charT, traits>& is, path& p);
39
40 template <class Source>
41 path u8path(const Source& source);
42 template <class InputIterator>
43 path u8path(InputIterator first, InputIterator last);
44
45 class filesystem_error;
46 class directory_entry;
47
48 class directory_iterator;
49
50 // enable directory_iterator range-based for statements
51 directory_iterator begin(directory_iterator iter) noexcept;
52 directory_iterator end(const directory_iterator&) noexcept;
53
54 class recursive_directory_iterator;
55
56 // enable recursive_directory_iterator range-based for statements
57 recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
58 recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
59
60 class file_status;
61
62 struct space_info
63 {
64 uintmax_t capacity;
65 uintmax_t free;
66 uintmax_t available;
67 };
68
69 enum class file_type;
70 enum class perms;
Eric Fiselier4f3dc0e2018-03-26 06:23:55 +000071 enum class perm_options;
Eric Fiselier435db152016-06-17 19:46:40 +000072 enum class copy_options;
73 enum class directory_options;
74
75 typedef chrono::time_point<trivial-clock> file_time_type;
76
77 // operational functions
78
Eric Fiselier91a182b2018-04-02 23:03:41 +000079 path absolute(const path& p);
80 path absolute(const path& p, error_code &ec);
Eric Fiselier435db152016-06-17 19:46:40 +000081
Eric Fiselier91a182b2018-04-02 23:03:41 +000082 path canonical(const path& p);
Eric Fiselier435db152016-06-17 19:46:40 +000083 path canonical(const path& p, error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +000084
85 void copy(const path& from, const path& to);
Eric Fiselierd56d5322017-10-30 18:59:59 +000086 void copy(const path& from, const path& to, error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +000087 void copy(const path& from, const path& to, copy_options options);
88 void copy(const path& from, const path& to, copy_options options,
Eric Fiselierd56d5322017-10-30 18:59:59 +000089 error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +000090
91 bool copy_file(const path& from, const path& to);
Eric Fiseliere1164812018-02-04 07:35:36 +000092 bool copy_file(const path& from, const path& to, error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +000093 bool copy_file(const path& from, const path& to, copy_options option);
94 bool copy_file(const path& from, const path& to, copy_options option,
Eric Fiseliere1164812018-02-04 07:35:36 +000095 error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +000096
97 void copy_symlink(const path& existing_symlink, const path& new_symlink);
98 void copy_symlink(const path& existing_symlink, const path& new_symlink,
Eric Fiselierd7c4ec82018-07-25 03:41:31 +000099 error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000100
101 bool create_directories(const path& p);
Eric Fiseliere1164812018-02-04 07:35:36 +0000102 bool create_directories(const path& p, error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +0000103
104 bool create_directory(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000105 bool create_directory(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000106
107 bool create_directory(const path& p, const path& attributes);
108 bool create_directory(const path& p, const path& attributes,
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000109 error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000110
111 void create_directory_symlink(const path& to, const path& new_symlink);
112 void create_directory_symlink(const path& to, const path& new_symlink,
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000113 error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000114
115 void create_hard_link(const path& to, const path& new_hard_link);
116 void create_hard_link(const path& to, const path& new_hard_link,
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000117 error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000118
119 void create_symlink(const path& to, const path& new_symlink);
120 void create_symlink(const path& to, const path& new_symlink,
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000121 error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000122
123 path current_path();
124 path current_path(error_code& ec);
125 void current_path(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000126 void current_path(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000127
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000128 bool exists(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000129 bool exists(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000130 bool exists(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000131
132 bool equivalent(const path& p1, const path& p2);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000133 bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000134
135 uintmax_t file_size(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000136 uintmax_t file_size(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000137
138 uintmax_t hard_link_count(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000139 uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000140
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000141 bool is_block_file(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000142 bool is_block_file(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000143 bool is_block_file(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000144
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000145 bool is_character_file(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000146 bool is_character_file(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000147 bool is_character_file(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000148
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000149 bool is_directory(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000150 bool is_directory(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000151 bool is_directory(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000152
153 bool is_empty(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000154 bool is_empty(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000155
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000156 bool is_fifo(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000157 bool is_fifo(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000158 bool is_fifo(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000159
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000160 bool is_other(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000161 bool is_other(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000162 bool is_other(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000163
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000164 bool is_regular_file(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000165 bool is_regular_file(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000166 bool is_regular_file(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000167
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000168 bool is_socket(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000169 bool is_socket(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000170 bool is_socket(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000171
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000172 bool is_symlink(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000173 bool is_symlink(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000174 bool is_symlink(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000175
176 file_time_type last_write_time(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000177 file_time_type last_write_time(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000178 void last_write_time(const path& p, file_time_type new_time);
179 void last_write_time(const path& p, file_time_type new_time,
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000180 error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000181
Eric Fiselier4f3dc0e2018-03-26 06:23:55 +0000182 void permissions(const path& p, perms prms,
183 perm_options opts=perm_options::replace);
184 void permissions(const path& p, perms prms, error_code& ec) noexcept;
185 void permissions(const path& p, perms prms, perm_options opts,
186 error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +0000187
Eric Fiselier91a182b2018-04-02 23:03:41 +0000188 path proximate(const path& p, error_code& ec);
189 path proximate(const path& p, const path& base = current_path());
190 path proximate(const path& p, const path& base, error_code &ec);
191
Eric Fiselier435db152016-06-17 19:46:40 +0000192 path read_symlink(const path& p);
193 path read_symlink(const path& p, error_code& ec);
194
Eric Fiselier91a182b2018-04-02 23:03:41 +0000195 path relative(const path& p, error_code& ec);
196 path relative(const path& p, const path& base=current_path());
197 path relative(const path& p, const path& base, error_code& ec);
198
Eric Fiselier435db152016-06-17 19:46:40 +0000199 bool remove(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000200 bool remove(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000201
202 uintmax_t remove_all(const path& p);
Eric Fiseliere1164812018-02-04 07:35:36 +0000203 uintmax_t remove_all(const path& p, error_code& ec);
Eric Fiselier435db152016-06-17 19:46:40 +0000204
205 void rename(const path& from, const path& to);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000206 void rename(const path& from, const path& to, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000207
208 void resize_file(const path& p, uintmax_t size);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000209 void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000210
211 space_info space(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000212 space_info space(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000213
214 file_status status(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000215 file_status status(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000216
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000217 bool status_known(file_status s) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000218
219 file_status symlink_status(const path& p);
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000220 file_status symlink_status(const path& p, error_code& ec) noexcept;
Eric Fiselier435db152016-06-17 19:46:40 +0000221
Eric Fiselier435db152016-06-17 19:46:40 +0000222 path temp_directory_path();
223 path temp_directory_path(error_code& ec);
224
Eric Fiselier91a182b2018-04-02 23:03:41 +0000225 path weakly_canonical(path const& p);
226 path weakly_canonical(path const& p, error_code& ec);
227
228
Eric Fiselier435db152016-06-17 19:46:40 +0000229} } } } // namespaces std::experimental::filesystem::v1
230
231*/
232
233#include <experimental/__config>
Eric Fiselier02cea5e2018-07-27 03:07:09 +0000234#include <filesystem>
Eric Fiselier435db152016-06-17 19:46:40 +0000235
236#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
237#pragma GCC system_header
238#endif
239
Eric Fiselier3ad58be2018-07-20 01:51:48 +0000240_LIBCPP_PUSH_MACROS
241#include <__undef_macros>
242
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000243#ifndef _LIBCPP_CXX03_LANG
244
Eric Fiselier435db152016-06-17 19:46:40 +0000245#define __cpp_lib_experimental_filesystem 201406
246
247_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
248
Eric Fiselier02cea5e2018-07-27 03:07:09 +0000249using namespace _VSTD_FS;
Eric Fiselier435db152016-06-17 19:46:40 +0000250
251_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
252
Eric Fiselierd7c4ec82018-07-25 03:41:31 +0000253#endif // !_LIBCPP_CXX03_LANG
254
Eric Fiselier3ad58be2018-07-20 01:51:48 +0000255_LIBCPP_POP_MACROS
256
Eric Fiselier435db152016-06-17 19:46:40 +0000257#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM