1// Filesystem operational functions -*- C++ -*- 
2 
3// Copyright (C) 2014-2021 Free Software Foundation, Inc. 
4// 
5// This file is part of the GNU ISO C++ Library. This library is free 
6// software; you can redistribute it and/or modify it under the 
7// terms of the GNU General Public License as published by the 
8// Free Software Foundation; either version 3, or (at your __option) 
9// any later version. 
10 
11// This library is distributed in the hope that it will be useful, 
12// but WITHOUT ANY WARRANTY; without even the implied warranty of 
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
14// GNU General Public License for more details. 
15 
16// Under Section 7 of GPL version 3, you are granted additional 
17// permissions described in the GCC Runtime Library Exception, version 
18// 3.1, as published by the Free Software Foundation. 
19 
20// You should have received a copy of the GNU General Public License and 
21// a copy of the GCC Runtime Library Exception along with this program; 
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 
23// <http://www.gnu.org/licenses/>. 
24 
25/** @file include/bits/fs_ops.h 
26 * This is an internal header file, included by other library headers. 
27 * Do not attempt to use it directly. @headername{filesystem} 
28 */ 
29 
30#ifndef _GLIBCXX_FS_OPS_H 
31#define _GLIBCXX_FS_OPS_H 1 
32 
33#if __cplusplus >= 201703L 
34 
35#include <cstdint> 
36 
37namespace std _GLIBCXX_VISIBILITY(default
38
39_GLIBCXX_BEGIN_NAMESPACE_VERSION 
40 
41namespace filesystem 
42
43 /** @addtogroup filesystem 
44 * @{ 
45 */ 
46 
47 [[nodiscard]] 
48 path absolute(const path& __p); 
49 
50 [[nodiscard]] 
51 path absolute(const path& __p, error_code& __ec); 
52 
53 [[nodiscard]] 
54 path canonical(const path& __p); 
55 
56 [[nodiscard]] 
57 path canonical(const path& __p, error_code& __ec); 
58 
59 inline void 
60 copy(const path& __from, const path& __to
61 { copy(__from, __to, options: copy_options::none); } 
62 
63 inline void 
64 copy(const path& __from, const path& __to, error_code& __ec
65 { copy(__from, __to, options: copy_options::none, __ec); } 
66 
67 void copy(const path& __from, const path& __to, copy_options __options); 
68 void copy(const path& __from, const path& __to, copy_options __options
69 error_code& __ec); 
70 
71 inline bool 
72 copy_file(const path& __from, const path& __to
73 { return copy_file(__from, __to, option: copy_options::none); } 
74 
75 inline bool 
76 copy_file(const path& __from, const path& __to, error_code& __ec
77 { return copy_file(__from, __to, option: copy_options::none, __ec); } 
78 
79 bool copy_file(const path& __from, const path& __to, copy_options __option); 
80 bool copy_file(const path& __from, const path& __to, copy_options __option
81 error_code& __ec); 
82 
83 void copy_symlink(const path& __existing_symlink, const path& __new_symlink); 
84 void copy_symlink(const path& __existing_symlink, const path& __new_symlink
85 error_code& __ec) noexcept
86 
87 bool create_directories(const path& __p); 
88 bool create_directories(const path& __p, error_code& __ec); 
89 
90 bool create_directory(const path& __p); 
91 bool create_directory(const path& __p, error_code& __ec) noexcept
92 
93 bool create_directory(const path& __p, const path& attributes); 
94 bool create_directory(const path& __p, const path& attributes
95 error_code& __ec) noexcept
96 
97 void create_directory_symlink(const path& __to, const path& __new_symlink); 
98 void create_directory_symlink(const path& __to, const path& __new_symlink
99 error_code& __ec) noexcept
100 
101 void create_hard_link(const path& __to, const path& __new_hard_link); 
102 void create_hard_link(const path& __to, const path& __new_hard_link
103 error_code& __ec) noexcept
104 
105 void create_symlink(const path& __to, const path& __new_symlink); 
106 void create_symlink(const path& __to, const path& __new_symlink
107 error_code& __ec) noexcept
108 
109 [[nodiscard]] 
110 path current_path(); 
111 
112 [[nodiscard]] 
113 path current_path(error_code& __ec); 
114 
115 void current_path(const path& __p); 
116 void current_path(const path& __p, error_code& __ec) noexcept
117 
118 [[nodiscard]] 
119 bool 
120 equivalent(const path& __p1, const path& __p2); 
121 
122 [[nodiscard]] 
123 bool 
124 equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept
125 
126 [[nodiscard]] 
127 inline bool 
128 exists(file_status __s) noexcept 
129 { return status_known(__s) && __s.type() != file_type::not_found; } 
130 
131 [[nodiscard]] 
132 inline bool 
133 exists(const path& __p
134 { return exists(s: status(__p)); } 
135 
136 [[nodiscard]] 
137 inline bool 
138 exists(const path& __p, error_code& __ec) noexcept 
139
140 auto __s = status(__p, __ec); 
141 if (status_known(__s)) 
142
143 __ec.clear(); 
144 return __s.type() != file_type::not_found
145
146 return false
147
148 
149 [[nodiscard]] 
150 uintmax_t file_size(const path& __p); 
151 
152 [[nodiscard]] 
153 uintmax_t file_size(const path& __p, error_code& __ec) noexcept
154 
155 [[nodiscard]] 
156 uintmax_t hard_link_count(const path& __p); 
157 
158 [[nodiscard]] 
159 uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept
160 
161 [[nodiscard]] 
162 inline bool 
163 is_block_file(file_status __s) noexcept 
164 { return __s.type() == file_type::block; } 
165 
166 [[nodiscard]] 
167 inline bool 
168 is_block_file(const path& __p
169 { return is_block_file(s: status(__p)); } 
170 
171 [[nodiscard]] 
172 inline bool 
173 is_block_file(const path& __p, error_code& __ec) noexcept 
174 { return is_block_file(s: status(__p, __ec)); } 
175 
176 [[nodiscard]] 
177 inline bool 
178 is_character_file(file_status __s) noexcept 
179 { return __s.type() == file_type::character; } 
180 
181 [[nodiscard]] 
182 inline bool 
183 is_character_file(const path& __p
184 { return is_character_file(s: status(__p)); } 
185 
186 [[nodiscard]] 
187 inline bool 
188 is_character_file(const path& __p, error_code& __ec) noexcept 
189 { return is_character_file(s: status(__p, __ec)); } 
190 
191 [[nodiscard]] 
192 inline bool 
193 is_directory(file_status __s) noexcept 
194 { return __s.type() == file_type::directory; } 
195 
196 [[nodiscard]] 
197 inline bool 
198 is_directory(const path& __p
199 { return is_directory(s: status(__p)); } 
200 
201 [[nodiscard]] 
202 inline bool 
203 is_directory(const path& __p, error_code& __ec) noexcept 
204 { return is_directory(s: status(__p, __ec)); } 
205 
206 [[nodiscard]] 
207 bool is_empty(const path& __p); 
208 
209 [[nodiscard]] 
210 bool is_empty(const path& __p, error_code& __ec); 
211 
212 [[nodiscard]] 
213 inline bool 
214 is_fifo(file_status __s) noexcept 
215 { return __s.type() == file_type::fifo; } 
216 
217 [[nodiscard]] 
218 inline bool 
219 is_fifo(const path& __p
220 { return is_fifo(s: status(__p)); } 
221 
222 [[nodiscard]] 
223 inline bool 
224 is_fifo(const path& __p, error_code& __ec) noexcept 
225 { return is_fifo(s: status(__p, __ec)); } 
226 
227 [[nodiscard]] 
228 inline bool 
229 is_other(file_status __s) noexcept 
230
231 return exists(__s) && !is_regular_file(__s) && !is_directory(__s
232 && !is_symlink(__s); 
233
234 
235 [[nodiscard]] 
236 inline bool 
237 is_other(const path& __p
238 { return is_other(s: status(__p)); } 
239 
240 [[nodiscard]] 
241 inline bool 
242 is_other(const path& __p, error_code& __ec) noexcept 
243 { return is_other(s: status(__p, __ec)); } 
244 
245 [[nodiscard]] 
246 inline bool 
247 is_regular_file(file_status __s) noexcept 
248 { return __s.type() == file_type::regular; } 
249 
250 [[nodiscard]] 
251 inline bool 
252 is_regular_file(const path& __p
253 { return is_regular_file(s: status(__p)); } 
254 
255 [[nodiscard]] 
256 inline bool 
257 is_regular_file(const path& __p, error_code& __ec) noexcept 
258 { return is_regular_file(s: status(__p, __ec)); } 
259 
260 [[nodiscard]] 
261 inline bool 
262 is_socket(file_status __s) noexcept 
263 { return __s.type() == file_type::socket; } 
264 
265 [[nodiscard]] 
266 inline bool 
267 is_socket(const path& __p
268 { return is_socket(s: status(__p)); } 
269 
270 [[nodiscard]] 
271 inline bool 
272 is_socket(const path& __p, error_code& __ec) noexcept 
273 { return is_socket(s: status(__p, __ec)); } 
274 
275 [[nodiscard]] 
276 inline bool 
277 is_symlink(file_status __s) noexcept 
278 { return __s.type() == file_type::symlink; } 
279 
280 [[nodiscard]] 
281 inline bool 
282 is_symlink(const path& __p
283 { return is_symlink(s: symlink_status(__p)); } 
284 
285 [[nodiscard]] 
286 inline bool 
287 is_symlink(const path& __p, error_code& __ec) noexcept 
288 { return is_symlink(s: symlink_status(__p, __ec)); } 
289 
290 [[nodiscard]] 
291 file_time_type last_write_time(const path& __p); 
292 
293 [[nodiscard]] 
294 file_time_type last_write_time(const path& __p, error_code& __ec) noexcept
295 
296 void last_write_time(const path& __p, file_time_type __new_time); 
297 void last_write_time(const path& __p, file_time_type __new_time
298 error_code& __ec) noexcept
299 
300 void 
301 permissions(const path& __p, perms __prms
302 perm_options __opts = perm_options::replace); 
303 
304 inline void 
305 permissions(const path& __p, perms __prms, error_code& __ec) noexcept 
306 { permissions(__p, __prms, perm_options::replace, __ec); } 
307 
308 void 
309 permissions(const path& __p, perms __prms, perm_options __opts
310 error_code& __ec) noexcept
311 
312 [[nodiscard]] 
313 inline path proximate(const path& __p, error_code& __ec
314 { return proximate(__p, base: current_path(), __ec); } 
315 
316 [[nodiscard]] 
317 path proximate(const path& __p, const path& __base = current_path()); 
318 
319 [[nodiscard]] 
320 path proximate(const path& __p, const path& __base, error_code& __ec); 
321 
322 [[nodiscard]] 
323 path read_symlink(const path& __p); 
324 
325 [[nodiscard]] 
326 path read_symlink(const path& __p, error_code& __ec); 
327 
328 [[nodiscard]] 
329 inline path relative(const path& __p, error_code& __ec
330 { return relative(__p, base: current_path(), __ec); } 
331 
332 [[nodiscard]] 
333 path relative(const path& __p, const path& __base = current_path()); 
334 
335 [[nodiscard]] 
336 path relative(const path& __p, const path& __base, error_code& __ec); 
337 
338 bool remove(const path& __p); 
339 bool remove(const path& __p, error_code& __ec) noexcept
340 
341 uintmax_t remove_all(const path& __p); 
342 uintmax_t remove_all(const path& __p, error_code& __ec); 
343 
344 void rename(const path& __from, const path& __to); 
345 void rename(const path& __from, const path& __to, error_code& __ec) noexcept
346 
347 void resize_file(const path& __p, uintmax_t __size); 
348 void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept
349 
350 [[nodiscard]] 
351 space_info space(const path& __p); 
352 
353 [[nodiscard]] 
354 space_info space(const path& __p, error_code& __ec) noexcept
355 
356 [[nodiscard]] 
357 file_status status(const path& __p); 
358 
359 [[nodiscard]] 
360 file_status status(const path& __p, error_code& __ec) noexcept
361 
362 [[nodiscard]] 
363 inline bool status_known(file_status __s) noexcept 
364 { return __s.type() != file_type::none; } 
365 
366 [[nodiscard]] 
367 file_status symlink_status(const path& __p); 
368 
369 [[nodiscard]] 
370 file_status symlink_status(const path& __p, error_code& __ec) noexcept
371 
372 [[nodiscard]] 
373 path temp_directory_path(); 
374 
375 [[nodiscard]] 
376 path temp_directory_path(error_code& __ec); 
377 
378 [[nodiscard]] 
379 path weakly_canonical(const path& __p); 
380 
381 [[nodiscard]] 
382 path weakly_canonical(const path& __p, error_code& __ec); 
383 
384 /// @} group filesystem 
385} // namespace filesystem 
386 
387_GLIBCXX_END_NAMESPACE_VERSION 
388} // namespace std 
389 
390#endif // C++17 
391 
392#endif // _GLIBCXX_FS_OPS_H 
393