Daily bump.
[official-gcc.git] / libstdc++-v3 / include / bits / fs_fwd.h
blob7e2bc30df30e318012d4f72772327ca4b67c20f5
1 // Filesystem declarations -*- C++ -*-
3 // Copyright (C) 2014-2024 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.
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.
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.
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/>.
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}
30 #ifndef _GLIBCXX_FS_FWD_H
31 #define _GLIBCXX_FS_FWD_H 1
33 #if __cplusplus >= 201703L
35 #include <system_error>
36 #include <cstdint>
37 #include <bits/chrono.h>
39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 /// ISO C++ 2017 namespace for File System library
44 namespace filesystem
46 #if _GLIBCXX_USE_CXX11_ABI
47 /// @cond undocumented
48 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
49 /// @endcond
50 #endif
52 /** @addtogroup filesystem
53 * @{
56 class file_status;
57 _GLIBCXX_BEGIN_NAMESPACE_CXX11
58 class path;
59 class filesystem_error;
60 class directory_entry;
61 class directory_iterator;
62 class recursive_directory_iterator;
63 _GLIBCXX_END_NAMESPACE_CXX11
65 /// Information about free space on a disk
66 struct space_info
68 uintmax_t capacity;
69 uintmax_t free;
70 uintmax_t available;
72 #if __cpp_impl_three_way_comparison >= 201907L
73 friend bool operator==(const space_info&, const space_info&) = default;
74 #endif
77 /// Enumerated type representing the type of a file
78 enum class file_type : signed char {
79 none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
80 block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
83 /// Bitmask type controlling effects of `filesystem::copy`
84 enum class copy_options : unsigned short {
85 none = 0,
86 skip_existing = 1, overwrite_existing = 2, update_existing = 4,
87 recursive = 8,
88 copy_symlinks = 16, skip_symlinks = 32,
89 directories_only = 64, create_symlinks = 128, create_hard_links = 256
92 /// @{
93 /// @relates copy_options
94 [[nodiscard]]
95 constexpr copy_options
96 operator&(copy_options __x, copy_options __y) noexcept
98 using __utype = typename std::underlying_type<copy_options>::type;
99 return static_cast<copy_options>(
100 static_cast<__utype>(__x) & static_cast<__utype>(__y));
103 [[nodiscard]]
104 constexpr copy_options
105 operator|(copy_options __x, copy_options __y) noexcept
107 using __utype = typename std::underlying_type<copy_options>::type;
108 return static_cast<copy_options>(
109 static_cast<__utype>(__x) | static_cast<__utype>(__y));
112 [[nodiscard]]
113 constexpr copy_options
114 operator^(copy_options __x, copy_options __y) noexcept
116 using __utype = typename std::underlying_type<copy_options>::type;
117 return static_cast<copy_options>(
118 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
121 [[nodiscard]]
122 constexpr copy_options
123 operator~(copy_options __x) noexcept
125 using __utype = typename std::underlying_type<copy_options>::type;
126 return static_cast<copy_options>(~static_cast<__utype>(__x));
129 inline copy_options&
130 operator&=(copy_options& __x, copy_options __y) noexcept
131 { return __x = __x & __y; }
133 inline copy_options&
134 operator|=(copy_options& __x, copy_options __y) noexcept
135 { return __x = __x | __y; }
137 inline copy_options&
138 operator^=(copy_options& __x, copy_options __y) noexcept
139 { return __x = __x ^ __y; }
140 /// @}
143 /// Bitmask type representing file access permissions
144 enum class perms : unsigned {
145 none = 0,
146 owner_read = 0400,
147 owner_write = 0200,
148 owner_exec = 0100,
149 owner_all = 0700,
150 group_read = 040,
151 group_write = 020,
152 group_exec = 010,
153 group_all = 070,
154 others_read = 04,
155 others_write = 02,
156 others_exec = 01,
157 others_all = 07,
158 all = 0777,
159 set_uid = 04000,
160 set_gid = 02000,
161 sticky_bit = 01000,
162 mask = 07777,
163 unknown = 0xFFFF,
166 /// @{
167 /// @relates perms
168 [[nodiscard]]
169 constexpr perms
170 operator&(perms __x, perms __y) noexcept
172 using __utype = typename std::underlying_type<perms>::type;
173 return static_cast<perms>(
174 static_cast<__utype>(__x) & static_cast<__utype>(__y));
177 [[nodiscard]]
178 constexpr perms
179 operator|(perms __x, perms __y) noexcept
181 using __utype = typename std::underlying_type<perms>::type;
182 return static_cast<perms>(
183 static_cast<__utype>(__x) | static_cast<__utype>(__y));
186 [[nodiscard]]
187 constexpr perms
188 operator^(perms __x, perms __y) noexcept
190 using __utype = typename std::underlying_type<perms>::type;
191 return static_cast<perms>(
192 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
195 [[nodiscard]]
196 constexpr perms
197 operator~(perms __x) noexcept
199 using __utype = typename std::underlying_type<perms>::type;
200 return static_cast<perms>(~static_cast<__utype>(__x));
203 inline perms&
204 operator&=(perms& __x, perms __y) noexcept
205 { return __x = __x & __y; }
207 inline perms&
208 operator|=(perms& __x, perms __y) noexcept
209 { return __x = __x | __y; }
211 inline perms&
212 operator^=(perms& __x, perms __y) noexcept
213 { return __x = __x ^ __y; }
214 /// @}
216 /// Bitmask type controlling changes to permissions
217 enum class perm_options : unsigned {
218 replace = 0x1,
219 add = 0x2,
220 remove = 0x4,
221 nofollow = 0x8
224 /// @{
225 /// @relates perm_options
226 [[nodiscard]]
227 constexpr perm_options
228 operator&(perm_options __x, perm_options __y) noexcept
230 using __utype = typename std::underlying_type<perm_options>::type;
231 return static_cast<perm_options>(
232 static_cast<__utype>(__x) & static_cast<__utype>(__y));
235 [[nodiscard]]
236 constexpr perm_options
237 operator|(perm_options __x, perm_options __y) noexcept
239 using __utype = typename std::underlying_type<perm_options>::type;
240 return static_cast<perm_options>(
241 static_cast<__utype>(__x) | static_cast<__utype>(__y));
244 [[nodiscard]]
245 constexpr perm_options
246 operator^(perm_options __x, perm_options __y) noexcept
248 using __utype = typename std::underlying_type<perm_options>::type;
249 return static_cast<perm_options>(
250 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
253 [[nodiscard]]
254 constexpr perm_options
255 operator~(perm_options __x) noexcept
257 using __utype = typename std::underlying_type<perm_options>::type;
258 return static_cast<perm_options>(~static_cast<__utype>(__x));
261 inline perm_options&
262 operator&=(perm_options& __x, perm_options __y) noexcept
263 { return __x = __x & __y; }
265 inline perm_options&
266 operator|=(perm_options& __x, perm_options __y) noexcept
267 { return __x = __x | __y; }
269 inline perm_options&
270 operator^=(perm_options& __x, perm_options __y) noexcept
271 { return __x = __x ^ __y; }
272 /// @}
274 /// Bitmask type controlling directory iteration
275 enum class directory_options : unsigned char {
276 none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
279 /// @{
280 /// @relates directory_options
281 [[nodiscard]]
282 constexpr directory_options
283 operator&(directory_options __x, directory_options __y) noexcept
285 using __utype = typename std::underlying_type<directory_options>::type;
286 return static_cast<directory_options>(
287 static_cast<__utype>(__x) & static_cast<__utype>(__y));
290 [[nodiscard]]
291 constexpr directory_options
292 operator|(directory_options __x, directory_options __y) noexcept
294 using __utype = typename std::underlying_type<directory_options>::type;
295 return static_cast<directory_options>(
296 static_cast<__utype>(__x) | static_cast<__utype>(__y));
299 [[nodiscard]]
300 constexpr directory_options
301 operator^(directory_options __x, directory_options __y) noexcept
303 using __utype = typename std::underlying_type<directory_options>::type;
304 return static_cast<directory_options>(
305 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
308 [[nodiscard]]
309 constexpr directory_options
310 operator~(directory_options __x) noexcept
312 using __utype = typename std::underlying_type<directory_options>::type;
313 return static_cast<directory_options>(~static_cast<__utype>(__x));
316 inline directory_options&
317 operator&=(directory_options& __x, directory_options __y) noexcept
318 { return __x = __x & __y; }
320 inline directory_options&
321 operator|=(directory_options& __x, directory_options __y) noexcept
322 { return __x = __x | __y; }
324 inline directory_options&
325 operator^=(directory_options& __x, directory_options __y) noexcept
326 { return __x = __x ^ __y; }
327 /// @}
329 /// The type used for file timestamps
330 using file_time_type = __file_clock::time_point;
332 // operational functions
334 void copy(const path& __from, const path& __to, copy_options __options);
335 void copy(const path& __from, const path& __to, copy_options __options,
336 error_code&);
338 bool copy_file(const path& __from, const path& __to, copy_options __option);
339 bool copy_file(const path& __from, const path& __to, copy_options __option,
340 error_code&);
342 path current_path();
344 bool exists(file_status) noexcept;
346 bool is_other(file_status) noexcept;
348 uintmax_t file_size(const path&);
349 uintmax_t file_size(const path&, error_code&) noexcept;
350 uintmax_t hard_link_count(const path&);
351 uintmax_t hard_link_count(const path&, error_code&) noexcept;
352 file_time_type last_write_time(const path&);
353 file_time_type last_write_time(const path&, error_code&) noexcept;
355 void permissions(const path&, perms, perm_options, error_code&) noexcept;
357 path proximate(const path& __p, const path& __base, error_code& __ec);
358 path proximate(const path& __p, const path& __base, error_code& __ec);
360 path relative(const path& __p, const path& __base, error_code& __ec);
362 file_status status(const path&);
363 file_status status(const path&, error_code&) noexcept;
365 bool status_known(file_status) noexcept;
367 file_status symlink_status(const path&);
368 file_status symlink_status(const path&, error_code&) noexcept;
370 bool is_regular_file(file_status) noexcept;
371 bool is_symlink(file_status) noexcept;
373 bool remove(const path&, error_code&) noexcept;
374 uintmax_t remove_all(const path&);
375 uintmax_t remove_all(const path&, error_code&);
377 /// @}
378 } // namespace filesystem
379 _GLIBCXX_END_NAMESPACE_VERSION
380 } // namespace std
381 #endif // C++17
382 #endif // _GLIBCXX_FS_FWD_H