1 | // Filesystem operational functions -*- C++ -*- |
2 | |
3 | // Copyright (C) 2014-2019 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_fwd.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 | |
37 | namespace std _GLIBCXX_VISIBILITY(default) |
38 | { |
39 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
40 | |
41 | namespace filesystem |
42 | { |
43 | /** |
44 | * @ingroup filesystem |
45 | * @{ |
46 | */ |
47 | |
48 | path absolute(const path& __p); |
49 | path absolute(const path& __p, error_code& __ec); |
50 | |
51 | path canonical(const path& __p); |
52 | path canonical(const path& __p, error_code& __ec); |
53 | |
54 | inline void |
55 | copy(const path& __from, const path& __to) |
56 | { copy(__from, __to, copy_options::none); } |
57 | |
58 | inline void |
59 | copy(const path& __from, const path& __to, error_code& __ec) |
60 | { copy(__from, __to, copy_options::none, __ec); } |
61 | |
62 | void copy(const path& __from, const path& __to, copy_options __options); |
63 | void copy(const path& __from, const path& __to, copy_options __options, |
64 | error_code& __ec); |
65 | |
66 | inline bool |
67 | copy_file(const path& __from, const path& __to) |
68 | { return copy_file(__from, __to, copy_options::none); } |
69 | |
70 | inline bool |
71 | copy_file(const path& __from, const path& __to, error_code& __ec) |
72 | { return copy_file(__from, __to, copy_options::none, __ec); } |
73 | |
74 | bool copy_file(const path& __from, const path& __to, copy_options __option); |
75 | bool copy_file(const path& __from, const path& __to, copy_options __option, |
76 | error_code& __ec); |
77 | |
78 | void copy_symlink(const path& __existing_symlink, const path& __new_symlink); |
79 | void copy_symlink(const path& __existing_symlink, const path& __new_symlink, |
80 | error_code& __ec) noexcept; |
81 | |
82 | bool create_directories(const path& __p); |
83 | bool create_directories(const path& __p, error_code& __ec); |
84 | |
85 | bool create_directory(const path& __p); |
86 | bool create_directory(const path& __p, error_code& __ec) noexcept; |
87 | |
88 | bool create_directory(const path& __p, const path& attributes); |
89 | bool create_directory(const path& __p, const path& attributes, |
90 | error_code& __ec) noexcept; |
91 | |
92 | void create_directory_symlink(const path& __to, const path& __new_symlink); |
93 | void create_directory_symlink(const path& __to, const path& __new_symlink, |
94 | error_code& __ec) noexcept; |
95 | |
96 | void create_hard_link(const path& __to, const path& __new_hard_link); |
97 | void create_hard_link(const path& __to, const path& __new_hard_link, |
98 | error_code& __ec) noexcept; |
99 | |
100 | void create_symlink(const path& __to, const path& __new_symlink); |
101 | void create_symlink(const path& __to, const path& __new_symlink, |
102 | error_code& __ec) noexcept; |
103 | |
104 | path current_path(); |
105 | path current_path(error_code& __ec); |
106 | void current_path(const path& __p); |
107 | void current_path(const path& __p, error_code& __ec) noexcept; |
108 | |
109 | bool |
110 | equivalent(const path& __p1, const path& __p2); |
111 | |
112 | bool |
113 | equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept; |
114 | |
115 | inline bool |
116 | exists(file_status __s) noexcept |
117 | { return status_known(__s) && __s.type() != file_type::not_found; } |
118 | |
119 | inline bool |
120 | exists(const path& __p) |
121 | { return exists(status(__p)); } |
122 | |
123 | inline bool |
124 | exists(const path& __p, error_code& __ec) noexcept |
125 | { |
126 | auto __s = status(__p, __ec); |
127 | if (status_known(__s)) |
128 | { |
129 | __ec.clear(); |
130 | return __s.type() != file_type::not_found; |
131 | } |
132 | return false; |
133 | } |
134 | |
135 | uintmax_t file_size(const path& __p); |
136 | uintmax_t file_size(const path& __p, error_code& __ec) noexcept; |
137 | |
138 | uintmax_t hard_link_count(const path& __p); |
139 | uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept; |
140 | |
141 | inline bool |
142 | is_block_file(file_status __s) noexcept |
143 | { return __s.type() == file_type::block; } |
144 | |
145 | inline bool |
146 | is_block_file(const path& __p) |
147 | { return is_block_file(status(__p)); } |
148 | |
149 | inline bool |
150 | is_block_file(const path& __p, error_code& __ec) noexcept |
151 | { return is_block_file(status(__p, __ec)); } |
152 | |
153 | inline bool |
154 | is_character_file(file_status __s) noexcept |
155 | { return __s.type() == file_type::character; } |
156 | |
157 | inline bool |
158 | is_character_file(const path& __p) |
159 | { return is_character_file(status(__p)); } |
160 | |
161 | inline bool |
162 | is_character_file(const path& __p, error_code& __ec) noexcept |
163 | { return is_character_file(status(__p, __ec)); } |
164 | |
165 | inline bool |
166 | is_directory(file_status __s) noexcept |
167 | { return __s.type() == file_type::directory; } |
168 | |
169 | inline bool |
170 | is_directory(const path& __p) |
171 | { return is_directory(status(__p)); } |
172 | |
173 | inline bool |
174 | is_directory(const path& __p, error_code& __ec) noexcept |
175 | { return is_directory(status(__p, __ec)); } |
176 | |
177 | bool is_empty(const path& __p); |
178 | bool is_empty(const path& __p, error_code& __ec); |
179 | |
180 | inline bool |
181 | is_fifo(file_status __s) noexcept |
182 | { return __s.type() == file_type::fifo; } |
183 | |
184 | inline bool |
185 | is_fifo(const path& __p) |
186 | { return is_fifo(status(__p)); } |
187 | |
188 | inline bool |
189 | is_fifo(const path& __p, error_code& __ec) noexcept |
190 | { return is_fifo(status(__p, __ec)); } |
191 | |
192 | inline bool |
193 | is_other(file_status __s) noexcept |
194 | { |
195 | return exists(__s) && !is_regular_file(__s) && !is_directory(__s) |
196 | && !is_symlink(__s); |
197 | } |
198 | |
199 | inline bool |
200 | is_other(const path& __p) |
201 | { return is_other(status(__p)); } |
202 | |
203 | inline bool |
204 | is_other(const path& __p, error_code& __ec) noexcept |
205 | { return is_other(status(__p, __ec)); } |
206 | |
207 | inline bool |
208 | is_regular_file(file_status __s) noexcept |
209 | { return __s.type() == file_type::regular; } |
210 | |
211 | inline bool |
212 | is_regular_file(const path& __p) |
213 | { return is_regular_file(status(__p)); } |
214 | |
215 | inline bool |
216 | is_regular_file(const path& __p, error_code& __ec) noexcept |
217 | { return is_regular_file(status(__p, __ec)); } |
218 | |
219 | inline bool |
220 | is_socket(file_status __s) noexcept |
221 | { return __s.type() == file_type::socket; } |
222 | |
223 | inline bool |
224 | is_socket(const path& __p) |
225 | { return is_socket(status(__p)); } |
226 | |
227 | inline bool |
228 | is_socket(const path& __p, error_code& __ec) noexcept |
229 | { return is_socket(status(__p, __ec)); } |
230 | |
231 | inline bool |
232 | is_symlink(file_status __s) noexcept |
233 | { return __s.type() == file_type::symlink; } |
234 | |
235 | inline bool |
236 | is_symlink(const path& __p) |
237 | { return is_symlink(symlink_status(__p)); } |
238 | |
239 | inline bool |
240 | is_symlink(const path& __p, error_code& __ec) noexcept |
241 | { return is_symlink(symlink_status(__p, __ec)); } |
242 | |
243 | file_time_type last_write_time(const path& __p); |
244 | file_time_type last_write_time(const path& __p, error_code& __ec) noexcept; |
245 | void last_write_time(const path& __p, file_time_type __new_time); |
246 | void last_write_time(const path& __p, file_time_type __new_time, |
247 | error_code& __ec) noexcept; |
248 | |
249 | void |
250 | permissions(const path& __p, perms __prms, |
251 | perm_options __opts = perm_options::replace); |
252 | |
253 | inline void |
254 | permissions(const path& __p, perms __prms, error_code& __ec) noexcept |
255 | { permissions(__p, __prms, perm_options::replace, __ec); } |
256 | |
257 | void |
258 | permissions(const path& __p, perms __prms, perm_options __opts, |
259 | error_code& __ec) noexcept; |
260 | |
261 | inline path proximate(const path& __p, error_code& __ec) |
262 | { return proximate(__p, current_path(), __ec); } |
263 | |
264 | path proximate(const path& __p, const path& __base = current_path()); |
265 | path proximate(const path& __p, const path& __base, error_code& __ec); |
266 | |
267 | path read_symlink(const path& __p); |
268 | path read_symlink(const path& __p, error_code& __ec); |
269 | |
270 | inline path relative(const path& __p, error_code& __ec) |
271 | { return relative(__p, current_path(), __ec); } |
272 | |
273 | path relative(const path& __p, const path& __base = current_path()); |
274 | path relative(const path& __p, const path& __base, error_code& __ec); |
275 | |
276 | bool remove(const path& __p); |
277 | bool remove(const path& __p, error_code& __ec) noexcept; |
278 | |
279 | uintmax_t remove_all(const path& __p); |
280 | uintmax_t remove_all(const path& __p, error_code& __ec); |
281 | |
282 | void rename(const path& __from, const path& __to); |
283 | void rename(const path& __from, const path& __to, error_code& __ec) noexcept; |
284 | |
285 | void resize_file(const path& __p, uintmax_t __size); |
286 | void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept; |
287 | |
288 | space_info space(const path& __p); |
289 | space_info space(const path& __p, error_code& __ec) noexcept; |
290 | |
291 | file_status status(const path& __p); |
292 | file_status status(const path& __p, error_code& __ec) noexcept; |
293 | |
294 | inline bool status_known(file_status __s) noexcept |
295 | { return __s.type() != file_type::none; } |
296 | |
297 | file_status symlink_status(const path& __p); |
298 | file_status symlink_status(const path& __p, error_code& __ec) noexcept; |
299 | |
300 | path temp_directory_path(); |
301 | path temp_directory_path(error_code& __ec); |
302 | |
303 | path weakly_canonical(const path& __p); |
304 | path weakly_canonical(const path& __p, error_code& __ec); |
305 | |
306 | /// @} group filesystem |
307 | } // namespace filesystem |
308 | |
309 | _GLIBCXX_END_NAMESPACE_VERSION |
310 | } // namespace std |
311 | |
312 | #endif // C++17 |
313 | |
314 | #endif // _GLIBCXX_FS_OPS_H |
315 | |