]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/experimental/bits/fs_fwd.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / include / experimental / bits / fs_fwd.h
CommitLineData
0ca7ba9a
JW
1// Filesystem declarations -*- C++ -*-
2
a945c346 3// Copyright (C) 2014-2024 Free Software Foundation, Inc.
0ca7ba9a
JW
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
6b4f8906
JW
25/** @file experimental/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{experimental/filesystem}
0ca7ba9a
JW
28 */
29
30#ifndef _GLIBCXX_EXPERIMENTAL_FS_FWD_H
31#define _GLIBCXX_EXPERIMENTAL_FS_FWD_H 1
32
33#if __cplusplus < 201103L
34# include <bits/c++0x_warning.h>
35#else
36
37#include <system_error>
38#include <cstdint>
7f78718b 39#include <bits/chrono.h>
0ca7ba9a
JW
40
41namespace std _GLIBCXX_VISIBILITY(default)
42{
4a15d842
FD
43_GLIBCXX_BEGIN_NAMESPACE_VERSION
44
0ca7ba9a
JW
45namespace experimental
46{
47namespace filesystem
48{
49inline namespace v1
50{
0ca7ba9a 51#if _GLIBCXX_USE_CXX11_ABI
e347987d 52inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
0ca7ba9a
JW
53#endif
54
55 /**
641cb5a6 56 * @defgroup filesystem-ts Filesystem TS
0ca7ba9a
JW
57 * @ingroup experimental
58 *
59 * Utilities for performing operations on file systems and their components,
60 * such as paths, regular files, and directories.
61 *
caace300 62 * ISO/IEC TS 18822:2015 C++ File System Technical Specification
f2ce64b5
JW
63 *
64 * @since C++11
65 *
66 * @remark Link using `-lstdc++fs` to use these types and functions.
67 *
0ca7ba9a
JW
68 * @{
69 */
70
71 class file_status;
72_GLIBCXX_BEGIN_NAMESPACE_CXX11
73 class path;
74 class filesystem_error;
75 class directory_entry;
76 class directory_iterator;
77 class recursive_directory_iterator;
78_GLIBCXX_END_NAMESPACE_CXX11
79
f2ce64b5 80 /// Information about free space on a disk
0ca7ba9a
JW
81 struct space_info
82 {
83 uintmax_t capacity;
84 uintmax_t free;
85 uintmax_t available;
86 };
87
f2ce64b5 88 /// Enumerated type representing the type of a file
0ca7ba9a
JW
89 enum class file_type : signed char {
90 none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
91 block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
92 };
93
f2ce64b5 94 /// Bitmask type controlling effects of `filesystem::copy`
0ca7ba9a
JW
95 enum class copy_options : unsigned short {
96 none = 0,
97 skip_existing = 1, overwrite_existing = 2, update_existing = 4,
98 recursive = 8,
99 copy_symlinks = 16, skip_symlinks = 32,
100 directories_only = 64, create_symlinks = 128, create_hard_links = 256
101 };
102
f2ce64b5
JW
103 /// @{
104 /// @relates copy_options
0ca7ba9a 105 constexpr copy_options
9c476ad4 106 operator&(copy_options __x, copy_options __y) noexcept
0ca7ba9a
JW
107 {
108 using __utype = typename std::underlying_type<copy_options>::type;
109 return static_cast<copy_options>(
110 static_cast<__utype>(__x) & static_cast<__utype>(__y));
111 }
112
113 constexpr copy_options
9c476ad4 114 operator|(copy_options __x, copy_options __y) noexcept
0ca7ba9a
JW
115 {
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));
119 }
120
121 constexpr copy_options
9c476ad4 122 operator^(copy_options __x, copy_options __y) noexcept
0ca7ba9a
JW
123 {
124 using __utype = typename std::underlying_type<copy_options>::type;
125 return static_cast<copy_options>(
126 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
127 }
128
129 constexpr copy_options
9c476ad4 130 operator~(copy_options __x) noexcept
0ca7ba9a
JW
131 {
132 using __utype = typename std::underlying_type<copy_options>::type;
133 return static_cast<copy_options>(~static_cast<__utype>(__x));
134 }
135
136 inline copy_options&
9c476ad4 137 operator&=(copy_options& __x, copy_options __y) noexcept
0ca7ba9a
JW
138 { return __x = __x & __y; }
139
140 inline copy_options&
9c476ad4 141 operator|=(copy_options& __x, copy_options __y) noexcept
0ca7ba9a
JW
142 { return __x = __x | __y; }
143
144 inline copy_options&
9c476ad4 145 operator^=(copy_options& __x, copy_options __y) noexcept
0ca7ba9a 146 { return __x = __x ^ __y; }
f2ce64b5 147 /// @}
0ca7ba9a 148
f2ce64b5 149 /// Bitmask type representing file access permissions
0ca7ba9a
JW
150 enum class perms : unsigned {
151 none = 0,
152 owner_read = 0400,
153 owner_write = 0200,
154 owner_exec = 0100,
155 owner_all = 0700,
156 group_read = 040,
157 group_write = 020,
158 group_exec = 010,
159 group_all = 070,
160 others_read = 04,
161 others_write = 02,
162 others_exec = 01,
163 others_all = 07,
164 all = 0777,
165 set_uid = 04000,
166 set_gid = 02000,
167 sticky_bit = 01000,
168 mask = 07777,
169 unknown = 0xFFFF,
170 add_perms = 0x10000,
171 remove_perms = 0x20000,
d17f7088 172 symlink_nofollow = 0x40000
0ca7ba9a
JW
173 };
174
f2ce64b5
JW
175 /// @{
176 /// @relates std::experimental::filesystem::perms
0ca7ba9a 177 constexpr perms
9c476ad4 178 operator&(perms __x, perms __y) noexcept
0ca7ba9a
JW
179 {
180 using __utype = typename std::underlying_type<perms>::type;
181 return static_cast<perms>(
182 static_cast<__utype>(__x) & static_cast<__utype>(__y));
183 }
184
185 constexpr perms
9c476ad4 186 operator|(perms __x, perms __y) noexcept
0ca7ba9a
JW
187 {
188 using __utype = typename std::underlying_type<perms>::type;
189 return static_cast<perms>(
190 static_cast<__utype>(__x) | static_cast<__utype>(__y));
191 }
192
193 constexpr perms
9c476ad4 194 operator^(perms __x, perms __y) noexcept
0ca7ba9a
JW
195 {
196 using __utype = typename std::underlying_type<perms>::type;
197 return static_cast<perms>(
198 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
199 }
200
201 constexpr perms
9c476ad4 202 operator~(perms __x) noexcept
0ca7ba9a
JW
203 {
204 using __utype = typename std::underlying_type<perms>::type;
205 return static_cast<perms>(~static_cast<__utype>(__x));
206 }
207
208 inline perms&
9c476ad4 209 operator&=(perms& __x, perms __y) noexcept
0ca7ba9a
JW
210 { return __x = __x & __y; }
211
212 inline perms&
9c476ad4 213 operator|=(perms& __x, perms __y) noexcept
0ca7ba9a
JW
214 { return __x = __x | __y; }
215
216 inline perms&
9c476ad4 217 operator^=(perms& __x, perms __y) noexcept
0ca7ba9a 218 { return __x = __x ^ __y; }
f2ce64b5 219 /// @}
0ca7ba9a 220
f2ce64b5 221 /// Bitmask type controlling directory iteration
0ca7ba9a
JW
222 enum class directory_options : unsigned char {
223 none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
224 };
225
f2ce64b5
JW
226 /// @{
227 /// @relates directory_options
0ca7ba9a 228 constexpr directory_options
9c476ad4 229 operator&(directory_options __x, directory_options __y) noexcept
0ca7ba9a
JW
230 {
231 using __utype = typename std::underlying_type<directory_options>::type;
232 return static_cast<directory_options>(
233 static_cast<__utype>(__x) & static_cast<__utype>(__y));
234 }
235
236 constexpr directory_options
9c476ad4 237 operator|(directory_options __x, directory_options __y) noexcept
0ca7ba9a
JW
238 {
239 using __utype = typename std::underlying_type<directory_options>::type;
240 return static_cast<directory_options>(
241 static_cast<__utype>(__x) | static_cast<__utype>(__y));
242 }
243
244 constexpr directory_options
9c476ad4 245 operator^(directory_options __x, directory_options __y) noexcept
0ca7ba9a
JW
246 {
247 using __utype = typename std::underlying_type<directory_options>::type;
248 return static_cast<directory_options>(
249 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
250 }
251
252 constexpr directory_options
9c476ad4 253 operator~(directory_options __x) noexcept
0ca7ba9a
JW
254 {
255 using __utype = typename std::underlying_type<directory_options>::type;
256 return static_cast<directory_options>(~static_cast<__utype>(__x));
257 }
258
259 inline directory_options&
9c476ad4 260 operator&=(directory_options& __x, directory_options __y) noexcept
0ca7ba9a
JW
261 { return __x = __x & __y; }
262
263 inline directory_options&
9c476ad4 264 operator|=(directory_options& __x, directory_options __y) noexcept
0ca7ba9a
JW
265 { return __x = __x | __y; }
266
267 inline directory_options&
9c476ad4 268 operator^=(directory_options& __x, directory_options __y) noexcept
0ca7ba9a 269 { return __x = __x ^ __y; }
f2ce64b5 270 /// @}
0ca7ba9a 271
f2ce64b5 272 /// The type used for file timestamps
fd5effb1 273 using file_time_type = std::chrono::system_clock::time_point;
0ca7ba9a
JW
274
275 // operational functions
276
277 void copy(const path& __from, const path& __to, copy_options __options);
278 void copy(const path& __from, const path& __to, copy_options __options,
279 error_code&) noexcept;
280
281 bool copy_file(const path& __from, const path& __to, copy_options __option);
282 bool copy_file(const path& __from, const path& __to, copy_options __option,
944da70a 283 error_code&);
0ca7ba9a
JW
284
285 path current_path();
286
287 file_status status(const path&);
288 file_status status(const path&, error_code&) noexcept;
289
290 bool status_known(file_status) noexcept;
291
292 file_status symlink_status(const path&);
293 file_status symlink_status(const path&, error_code&) noexcept;
294
295 bool is_regular_file(file_status) noexcept;
296 bool is_symlink(file_status) noexcept;
297
f0b88346 298 /// @} group filesystem-ts
0ca7ba9a
JW
299} // namespace v1
300} // namespace filesystem
301} // namespace experimental
4a15d842
FD
302
303_GLIBCXX_END_NAMESPACE_VERSION
0ca7ba9a
JW
304} // namespace std
305
306#endif // C++11
307
308#endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H