libstdc++
experimental/bits/fs_ops.h
Go to the documentation of this file.
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 experimental/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{experimental/filesystem}
28 */
29
30#ifndef _GLIBCXX_EXPERIMENTAL_FS_OPS_H
31#define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1
32
33#if __cplusplus < 201103L
34# include <bits/c++0x_warning.h>
35#else
36
37#include <cstdint>
38
39namespace std _GLIBCXX_VISIBILITY(default)
40{
41_GLIBCXX_BEGIN_NAMESPACE_VERSION
42
43namespace experimental
44{
45namespace filesystem
46{
47inline namespace v1
48{
49 /**
50 * @addtogroup filesystem-ts
51 * @{
52 */
53
54 [[__nodiscard__]]
55 path absolute(const path& __p, const path& __base = current_path());
56
57 [[__nodiscard__]]
58 path canonical(const path& __p, const path& __base = current_path());
59
60 [[__nodiscard__]]
61 path canonical(const path& __p, error_code& __ec);
62
63 [[__nodiscard__]]
64 path canonical(const path& __p, const path& __base, error_code& __ec);
65
66 inline void
67 copy(const path& __from, const path& __to)
68 { copy(__from, __to, copy_options::none); }
69
70 inline void
71 copy(const path& __from, const path& __to, error_code& __ec) noexcept
72 { copy(__from, __to, copy_options::none, __ec); }
73
74 void copy(const path& __from, const path& __to, copy_options __options);
75
76 void copy(const path& __from, const path& __to, copy_options __options,
77 error_code& __ec) noexcept;
78
79 inline bool
80 copy_file(const path& __from, const path& __to)
81 { return copy_file(__from, __to, copy_options::none); }
82
83 inline bool
84 copy_file(const path& __from, const path& __to, error_code& __ec)
85 { return copy_file(__from, __to, copy_options::none, __ec); }
86
87 bool copy_file(const path& __from, const path& __to, copy_options __option);
88 bool copy_file(const path& __from, const path& __to, copy_options __option,
89 error_code& __ec);
90
91 void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
92 void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
93 error_code& __ec) noexcept;
94
95 bool create_directories(const path& __p);
96 bool create_directories(const path& __p, error_code& __ec);
97
98 bool create_directory(const path& __p);
99 bool create_directory(const path& __p, error_code& __ec) noexcept;
100
101 bool create_directory(const path& __p, const path& attributes);
102 bool create_directory(const path& __p, const path& attributes,
103 error_code& __ec) noexcept;
104
105 void create_directory_symlink(const path& __to, const path& __new_symlink);
106 void create_directory_symlink(const path& __to, const path& __new_symlink,
107 error_code& __ec) noexcept;
108
109 void create_hard_link(const path& __to, const path& __new_hard_link);
110 void create_hard_link(const path& __to, const path& __new_hard_link,
111 error_code& __ec) noexcept;
112
113 void create_symlink(const path& __to, const path& __new_symlink);
114 void create_symlink(const path& __to, const path& __new_symlink,
115 error_code& __ec) noexcept;
116
117 [[__nodiscard__]]
118 path current_path();
119
120 [[__nodiscard__]]
121 path current_path(error_code& __ec);
122
123 void current_path(const path& __p);
124 void current_path(const path& __p, error_code& __ec) noexcept;
125
126 [[__nodiscard__]]
127 bool
128 equivalent(const path& __p1, const path& __p2);
129
130 [[__nodiscard__]]
131 bool
132 equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
133
134 [[__nodiscard__]]
135 inline bool
136 exists(file_status __s) noexcept
137 { return status_known(__s) && __s.type() != file_type::not_found; }
138
139 [[__nodiscard__]]
140 inline bool
141 exists(const path& __p)
142 { return exists(status(__p)); }
143
144 [[__nodiscard__]]
145 inline bool
146 exists(const path& __p, error_code& __ec) noexcept
147 {
148 auto __s = status(__p, __ec);
149 if (status_known(__s))
150 {
151 __ec.clear();
152 return __s.type() != file_type::not_found;
153 }
154 return false;
155 }
156
157 [[__nodiscard__]]
158 uintmax_t file_size(const path& __p);
159
160 [[__nodiscard__]]
161 uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
162
163 [[__nodiscard__]]
164 uintmax_t hard_link_count(const path& __p);
165
166 [[__nodiscard__]]
167 uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
168
169 [[__nodiscard__]]
170 inline bool
171 is_block_file(file_status __s) noexcept
172 { return __s.type() == file_type::block; }
173
174 [[__nodiscard__]]
175 inline bool
176 is_block_file(const path& __p)
177 { return is_block_file(status(__p)); }
178
179 [[__nodiscard__]]
180 inline bool
181 is_block_file(const path& __p, error_code& __ec) noexcept
182 { return is_block_file(status(__p, __ec)); }
183
184 [[__nodiscard__]]
185 inline bool
186 is_character_file(file_status __s) noexcept
187 { return __s.type() == file_type::character; }
188
189 [[__nodiscard__]]
190 inline bool
191 is_character_file(const path& __p)
192 { return is_character_file(status(__p)); }
193
194 [[__nodiscard__]]
195 inline bool
196 is_character_file(const path& __p, error_code& __ec) noexcept
197 { return is_character_file(status(__p, __ec)); }
198
199 [[__nodiscard__]]
200 inline bool
201 is_directory(file_status __s) noexcept
202 { return __s.type() == file_type::directory; }
203
204 [[__nodiscard__]]
205 inline bool
206 is_directory(const path& __p)
207 { return is_directory(status(__p)); }
208
209 [[__nodiscard__]]
210 inline bool
211 is_directory(const path& __p, error_code& __ec) noexcept
212 { return is_directory(status(__p, __ec)); }
213
214 [[__nodiscard__]]
215 bool is_empty(const path& __p);
216 [[__nodiscard__]]
217 bool is_empty(const path& __p, error_code& __ec) noexcept;
218
219 [[__nodiscard__]]
220 inline bool
221 is_fifo(file_status __s) noexcept
222 { return __s.type() == file_type::fifo; }
223
224 [[__nodiscard__]]
225 inline bool
226 is_fifo(const path& __p)
227 { return is_fifo(status(__p)); }
228
229 [[__nodiscard__]]
230 inline bool
231 is_fifo(const path& __p, error_code& __ec) noexcept
232 { return is_fifo(status(__p, __ec)); }
233
234 [[__nodiscard__]]
235 inline bool
236 is_other(file_status __s) noexcept
237 {
238 return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
239 && !is_symlink(__s);
240 }
241
242 [[__nodiscard__]]
243 inline bool
244 is_other(const path& __p)
245 { return is_other(status(__p)); }
246
247 [[__nodiscard__]]
248 inline bool
249 is_other(const path& __p, error_code& __ec) noexcept
250 { return is_other(status(__p, __ec)); }
251
252 [[__nodiscard__]]
253 inline bool
254 is_regular_file(file_status __s) noexcept
255 { return __s.type() == file_type::regular; }
256
257 [[__nodiscard__]]
258 inline bool
259 is_regular_file(const path& __p)
260 { return is_regular_file(status(__p)); }
261
262 [[__nodiscard__]]
263 inline bool
264 is_regular_file(const path& __p, error_code& __ec) noexcept
265 { return is_regular_file(status(__p, __ec)); }
266
267 [[__nodiscard__]]
268 inline bool
269 is_socket(file_status __s) noexcept
270 { return __s.type() == file_type::socket; }
271
272 [[__nodiscard__]]
273 inline bool
274 is_socket(const path& __p)
275 { return is_socket(status(__p)); }
276
277 [[__nodiscard__]]
278 inline bool
279 is_socket(const path& __p, error_code& __ec) noexcept
280 { return is_socket(status(__p, __ec)); }
281
282 [[__nodiscard__]]
283 inline bool
284 is_symlink(file_status __s) noexcept
285 { return __s.type() == file_type::symlink; }
286
287 [[__nodiscard__]]
288 inline bool
289 is_symlink(const path& __p)
290 { return is_symlink(symlink_status(__p)); }
291
292 [[__nodiscard__]]
293 inline bool
294 is_symlink(const path& __p, error_code& __ec) noexcept
295 { return is_symlink(symlink_status(__p, __ec)); }
296
297 [[__nodiscard__]]
298 file_time_type last_write_time(const path& __p);
299
300 [[__nodiscard__]]
301 file_time_type last_write_time(const path& __p, error_code& __ec) noexcept;
302
303 void last_write_time(const path& __p, file_time_type __new_time);
304 void last_write_time(const path& __p, file_time_type __new_time,
305 error_code& __ec) noexcept;
306
307 void permissions(const path& __p, perms __prms);
308 void permissions(const path& __p, perms __prms, error_code& __ec) noexcept;
309
310 [[__nodiscard__]]
311 path read_symlink(const path& __p);
312
313 [[__nodiscard__]]
314 path read_symlink(const path& __p, error_code& __ec);
315
316 bool remove(const path& __p);
317 bool remove(const path& __p, error_code& __ec) noexcept;
318
319 uintmax_t remove_all(const path& __p);
320 uintmax_t remove_all(const path& __p, error_code& __ec);
321
322 void rename(const path& __from, const path& __to);
323 void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
324
325 void resize_file(const path& __p, uintmax_t __size);
326 void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
327
328 [[__nodiscard__]]
329 space_info space(const path& __p);
330
331 [[__nodiscard__]]
332 space_info space(const path& __p, error_code& __ec) noexcept;
333
334 [[__nodiscard__]]
335 file_status status(const path& __p);
336
337 [[__nodiscard__]]
338 file_status status(const path& __p, error_code& __ec) noexcept;
339
340 [[__nodiscard__]]
341 inline bool status_known(file_status __s) noexcept
342 { return __s.type() != file_type::none; }
343
344 [[__nodiscard__]]
345 file_status symlink_status(const path& __p);
346
347 [[__nodiscard__]]
348 file_status symlink_status(const path& __p, error_code& __ec) noexcept;
349
350 [[__nodiscard__]]
351 path system_complete(const path& __p);
352
353 [[__nodiscard__]]
354 path system_complete(const path& __p, error_code& __ec);
355
356 [[__nodiscard__]]
357 path temp_directory_path();
358
359 [[__nodiscard__]]
360 path temp_directory_path(error_code& __ec);
361
362 /// @} group filesystem-ts
363} // namespace v1
364} // namespace filesystem
365} // namespace experimental
366
367_GLIBCXX_END_NAMESPACE_VERSION
368} // namespace std
369
370#endif // C++11
371
372#endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H
perms
Bitmask type representing file access permissions.
std::chrono::system_clock::time_point file_time_type
The type used for file timestamps.
copy_options
Bitmask type controlling effects of filesystem::copy
ISO C++ entities toplevel namespace is std.