2 //===--------------------------- filesystem -------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM
11 #define _LIBCPP_EXPERIMENTAL_FILESYSTEM
15 namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
19 void swap(path& lhs, path& rhs) noexcept;
20 size_t hash_value(const path& p) 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 bool operator>=(const path& lhs, const path& rhs) noexcept;
29 path operator/ (const path& lhs, const path& rhs);
31 // fs.path.io operators are friends of path.
32 template <class charT, class traits>
33 friend basic_ostream<charT, traits>&
34 operator<<(basic_ostream<charT, traits>& os, const path& p);
36 template <class charT, class traits>
37 friend basic_istream<charT, traits>&
38 operator>>(basic_istream<charT, traits>& is, path& p);
40 template <class Source>
41 path u8path(const Source& source);
42 template <class InputIterator>
43 path u8path(InputIterator first, InputIterator last);
45 class filesystem_error;
46 class directory_entry;
48 class directory_iterator;
50 // enable directory_iterator range-based for statements
51 directory_iterator begin(directory_iterator iter) noexcept;
52 directory_iterator end(const directory_iterator&) noexcept;
54 class recursive_directory_iterator;
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;
71 enum class perm_options;
72 enum class copy_options;
73 enum class directory_options;
75 typedef chrono::time_point<trivial-clock> file_time_type;
77 // operational functions
79 path absolute(const path& p);
80 path absolute(const path& p, error_code &ec);
82 path canonical(const path& p);
83 path canonical(const path& p, error_code& ec);
85 void copy(const path& from, const path& to);
86 void copy(const path& from, const path& to, error_code& ec);
87 void copy(const path& from, const path& to, copy_options options);
88 void copy(const path& from, const path& to, copy_options options,
91 bool copy_file(const path& from, const path& to);
92 bool copy_file(const path& from, const path& to, error_code& ec);
93 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,
97 void copy_symlink(const path& existing_symlink, const path& new_symlink);
98 void copy_symlink(const path& existing_symlink, const path& new_symlink,
99 error_code& ec) noexcept;
101 bool create_directories(const path& p);
102 bool create_directories(const path& p, error_code& ec);
104 bool create_directory(const path& p);
105 bool create_directory(const path& p, error_code& ec) noexcept;
107 bool create_directory(const path& p, const path& attributes);
108 bool create_directory(const path& p, const path& attributes,
109 error_code& ec) noexcept;
111 void create_directory_symlink(const path& to, const path& new_symlink);
112 void create_directory_symlink(const path& to, const path& new_symlink,
113 error_code& ec) noexcept;
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,
117 error_code& ec) noexcept;
119 void create_symlink(const path& to, const path& new_symlink);
120 void create_symlink(const path& to, const path& new_symlink,
121 error_code& ec) noexcept;
124 path current_path(error_code& ec);
125 void current_path(const path& p);
126 void current_path(const path& p, error_code& ec) noexcept;
128 bool exists(file_status s) noexcept;
129 bool exists(const path& p);
130 bool exists(const path& p, error_code& ec) noexcept;
132 bool equivalent(const path& p1, const path& p2);
133 bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
135 uintmax_t file_size(const path& p);
136 uintmax_t file_size(const path& p, error_code& ec) noexcept;
138 uintmax_t hard_link_count(const path& p);
139 uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
141 bool is_block_file(file_status s) noexcept;
142 bool is_block_file(const path& p);
143 bool is_block_file(const path& p, error_code& ec) noexcept;
145 bool is_character_file(file_status s) noexcept;
146 bool is_character_file(const path& p);
147 bool is_character_file(const path& p, error_code& ec) noexcept;
149 bool is_directory(file_status s) noexcept;
150 bool is_directory(const path& p);
151 bool is_directory(const path& p, error_code& ec) noexcept;
153 bool is_empty(const path& p);
154 bool is_empty(const path& p, error_code& ec) noexcept;
156 bool is_fifo(file_status s) noexcept;
157 bool is_fifo(const path& p);
158 bool is_fifo(const path& p, error_code& ec) noexcept;
160 bool is_other(file_status s) noexcept;
161 bool is_other(const path& p);
162 bool is_other(const path& p, error_code& ec) noexcept;
164 bool is_regular_file(file_status s) noexcept;
165 bool is_regular_file(const path& p);
166 bool is_regular_file(const path& p, error_code& ec) noexcept;
168 bool is_socket(file_status s) noexcept;
169 bool is_socket(const path& p);
170 bool is_socket(const path& p, error_code& ec) noexcept;
172 bool is_symlink(file_status s) noexcept;
173 bool is_symlink(const path& p);
174 bool is_symlink(const path& p, error_code& ec) noexcept;
176 file_time_type last_write_time(const path& p);
177 file_time_type last_write_time(const path& p, error_code& ec) noexcept;
178 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,
180 error_code& ec) noexcept;
182 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,
188 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);
192 path read_symlink(const path& p);
193 path read_symlink(const path& p, error_code& ec);
195 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);
199 bool remove(const path& p);
200 bool remove(const path& p, error_code& ec) noexcept;
202 uintmax_t remove_all(const path& p);
203 uintmax_t remove_all(const path& p, error_code& ec);
205 void rename(const path& from, const path& to);
206 void rename(const path& from, const path& to, error_code& ec) noexcept;
208 void resize_file(const path& p, uintmax_t size);
209 void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
211 space_info space(const path& p);
212 space_info space(const path& p, error_code& ec) noexcept;
214 file_status status(const path& p);
215 file_status status(const path& p, error_code& ec) noexcept;
217 bool status_known(file_status s) noexcept;
219 file_status symlink_status(const path& p);
220 file_status symlink_status(const path& p, error_code& ec) noexcept;
222 path temp_directory_path();
223 path temp_directory_path(error_code& ec);
225 path weakly_canonical(path const& p);
226 path weakly_canonical(path const& p, error_code& ec);
229 } } } } // namespaces std::experimental::filesystem::v1
233 #include <experimental/__config>
234 #include <filesystem>
236 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
237 #pragma GCC system_header
241 #include <__undef_macros>
243 #ifndef _LIBCPP_CXX03_LANG
245 #define __cpp_lib_experimental_filesystem 201406
247 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
249 using namespace _VSTD_FS;
251 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
253 #endif // !_LIBCPP_CXX03_LANG
257 #endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM