libstdc++
bits/fs_fwd.h
Go to the documentation of this file.
1// Filesystem declarations -*- C++ -*-
2
3// Copyright (C) 2014-2020 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_FWD_H
31#define _GLIBCXX_FS_FWD_H 1
32
33#if __cplusplus >= 201703L
34
35#include <system_error>
36#include <cstdint>
37#include <chrono>
38
39namespace std _GLIBCXX_VISIBILITY(default)
40{
41_GLIBCXX_BEGIN_NAMESPACE_VERSION
42
43/** @addtogroup filesystem
44 * @{
45 */
46
47/// ISO C++ 2017 namespace for File System library
48namespace filesystem
49{
50#if _GLIBCXX_USE_CXX11_ABI
51inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
52#endif
53
54
55 class file_status;
56_GLIBCXX_BEGIN_NAMESPACE_CXX11
57 class path;
58 class filesystem_error;
59 class directory_entry;
60 class directory_iterator;
61 class recursive_directory_iterator;
62_GLIBCXX_END_NAMESPACE_CXX11
63
64 struct space_info
65 {
66 uintmax_t capacity;
67 uintmax_t free;
68 uintmax_t available;
69 };
70
71 enum class file_type : signed char {
72 none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
73 block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
74 };
75
76 /// Bitmask type
77 enum class copy_options : unsigned short {
78 none = 0,
79 skip_existing = 1, overwrite_existing = 2, update_existing = 4,
80 recursive = 8,
81 copy_symlinks = 16, skip_symlinks = 32,
82 directories_only = 64, create_symlinks = 128, create_hard_links = 256
83 };
84
85 constexpr copy_options
86 operator&(copy_options __x, copy_options __y) noexcept
87 {
88 using __utype = typename std::underlying_type<copy_options>::type;
89 return static_cast<copy_options>(
90 static_cast<__utype>(__x) & static_cast<__utype>(__y));
91 }
92
93 constexpr copy_options
94 operator|(copy_options __x, copy_options __y) noexcept
95 {
96 using __utype = typename std::underlying_type<copy_options>::type;
97 return static_cast<copy_options>(
98 static_cast<__utype>(__x) | static_cast<__utype>(__y));
99 }
100
101 constexpr copy_options
102 operator^(copy_options __x, copy_options __y) noexcept
103 {
104 using __utype = typename std::underlying_type<copy_options>::type;
105 return static_cast<copy_options>(
106 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
107 }
108
109 constexpr copy_options
110 operator~(copy_options __x) noexcept
111 {
112 using __utype = typename std::underlying_type<copy_options>::type;
113 return static_cast<copy_options>(~static_cast<__utype>(__x));
114 }
115
116 inline copy_options&
117 operator&=(copy_options& __x, copy_options __y) noexcept
118 { return __x = __x & __y; }
119
120 inline copy_options&
121 operator|=(copy_options& __x, copy_options __y) noexcept
122 { return __x = __x | __y; }
123
124 inline copy_options&
125 operator^=(copy_options& __x, copy_options __y) noexcept
126 { return __x = __x ^ __y; }
127
128
129 /// Bitmask type
130 enum class perms : unsigned {
131 none = 0,
132 owner_read = 0400,
133 owner_write = 0200,
134 owner_exec = 0100,
135 owner_all = 0700,
136 group_read = 040,
137 group_write = 020,
138 group_exec = 010,
139 group_all = 070,
140 others_read = 04,
141 others_write = 02,
142 others_exec = 01,
143 others_all = 07,
144 all = 0777,
145 set_uid = 04000,
146 set_gid = 02000,
147 sticky_bit = 01000,
148 mask = 07777,
149 unknown = 0xFFFF,
150 };
151
152 constexpr perms
153 operator&(perms __x, perms __y) noexcept
154 {
155 using __utype = typename std::underlying_type<perms>::type;
156 return static_cast<perms>(
157 static_cast<__utype>(__x) & static_cast<__utype>(__y));
158 }
159
160 constexpr perms
161 operator|(perms __x, perms __y) noexcept
162 {
163 using __utype = typename std::underlying_type<perms>::type;
164 return static_cast<perms>(
165 static_cast<__utype>(__x) | static_cast<__utype>(__y));
166 }
167
168 constexpr perms
169 operator^(perms __x, perms __y) noexcept
170 {
171 using __utype = typename std::underlying_type<perms>::type;
172 return static_cast<perms>(
173 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
174 }
175
176 constexpr perms
177 operator~(perms __x) noexcept
178 {
179 using __utype = typename std::underlying_type<perms>::type;
180 return static_cast<perms>(~static_cast<__utype>(__x));
181 }
182
183 inline perms&
184 operator&=(perms& __x, perms __y) noexcept
185 { return __x = __x & __y; }
186
187 inline perms&
188 operator|=(perms& __x, perms __y) noexcept
189 { return __x = __x | __y; }
190
191 inline perms&
192 operator^=(perms& __x, perms __y) noexcept
193 { return __x = __x ^ __y; }
194
195 /// Bitmask type
196 enum class perm_options : unsigned {
197 replace = 0x1,
198 add = 0x2,
199 remove = 0x4,
200 nofollow = 0x8
201 };
202
203 constexpr perm_options
204 operator&(perm_options __x, perm_options __y) noexcept
205 {
206 using __utype = typename std::underlying_type<perm_options>::type;
207 return static_cast<perm_options>(
208 static_cast<__utype>(__x) & static_cast<__utype>(__y));
209 }
210
211 constexpr perm_options
212 operator|(perm_options __x, perm_options __y) noexcept
213 {
214 using __utype = typename std::underlying_type<perm_options>::type;
215 return static_cast<perm_options>(
216 static_cast<__utype>(__x) | static_cast<__utype>(__y));
217 }
218
219 constexpr perm_options
220 operator^(perm_options __x, perm_options __y) noexcept
221 {
222 using __utype = typename std::underlying_type<perm_options>::type;
223 return static_cast<perm_options>(
224 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
225 }
226
227 constexpr perm_options
228 operator~(perm_options __x) noexcept
229 {
230 using __utype = typename std::underlying_type<perm_options>::type;
231 return static_cast<perm_options>(~static_cast<__utype>(__x));
232 }
233
234 inline perm_options&
235 operator&=(perm_options& __x, perm_options __y) noexcept
236 { return __x = __x & __y; }
237
238 inline perm_options&
239 operator|=(perm_options& __x, perm_options __y) noexcept
240 { return __x = __x | __y; }
241
242 inline perm_options&
243 operator^=(perm_options& __x, perm_options __y) noexcept
244 { return __x = __x ^ __y; }
245
246 // Bitmask type
247 enum class directory_options : unsigned char {
248 none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
249 };
250
251 constexpr directory_options
252 operator&(directory_options __x, directory_options __y) noexcept
253 {
254 using __utype = typename std::underlying_type<directory_options>::type;
255 return static_cast<directory_options>(
256 static_cast<__utype>(__x) & static_cast<__utype>(__y));
257 }
258
259 constexpr directory_options
260 operator|(directory_options __x, directory_options __y) noexcept
261 {
262 using __utype = typename std::underlying_type<directory_options>::type;
263 return static_cast<directory_options>(
264 static_cast<__utype>(__x) | static_cast<__utype>(__y));
265 }
266
267 constexpr directory_options
268 operator^(directory_options __x, directory_options __y) noexcept
269 {
270 using __utype = typename std::underlying_type<directory_options>::type;
271 return static_cast<directory_options>(
272 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
273 }
274
275 constexpr directory_options
276 operator~(directory_options __x) noexcept
277 {
278 using __utype = typename std::underlying_type<directory_options>::type;
279 return static_cast<directory_options>(~static_cast<__utype>(__x));
280 }
281
282 inline directory_options&
283 operator&=(directory_options& __x, directory_options __y) noexcept
284 { return __x = __x & __y; }
285
286 inline directory_options&
287 operator|=(directory_options& __x, directory_options __y) noexcept
288 { return __x = __x | __y; }
289
290 inline directory_options&
291 operator^=(directory_options& __x, directory_options __y) noexcept
292 { return __x = __x ^ __y; }
293
294 using file_time_type = __file_clock::time_point;
295
296 // operational functions
297
298 void copy(const path& __from, const path& __to, copy_options __options);
299 void copy(const path& __from, const path& __to, copy_options __options,
300 error_code&);
301
302 bool copy_file(const path& __from, const path& __to, copy_options __option);
303 bool copy_file(const path& __from, const path& __to, copy_options __option,
304 error_code&);
305
306 path current_path();
307
308 bool exists(file_status) noexcept;
309
310 bool is_other(file_status) noexcept;
311
312 uintmax_t file_size(const path&);
313 uintmax_t file_size(const path&, error_code&) noexcept;
314 uintmax_t hard_link_count(const path&);
315 uintmax_t hard_link_count(const path&, error_code&) noexcept;
316 file_time_type last_write_time(const path&);
317 file_time_type last_write_time(const path&, error_code&) noexcept;
318
319 void permissions(const path&, perms, perm_options, error_code&) noexcept;
320
321 path proximate(const path& __p, const path& __base, error_code& __ec);
322 path proximate(const path& __p, const path& __base, error_code& __ec);
323
324 path relative(const path& __p, const path& __base, error_code& __ec);
325
326 file_status status(const path&);
327 file_status status(const path&, error_code&) noexcept;
328
329 bool status_known(file_status) noexcept;
330
331 file_status symlink_status(const path&);
332 file_status symlink_status(const path&, error_code&) noexcept;
333
334 bool is_regular_file(file_status) noexcept;
335 bool is_symlink(file_status) noexcept;
336
337} // namespace filesystem
338// @}
339_GLIBCXX_END_NAMESPACE_VERSION
340} // namespace std
341#endif // C++17
342#endif // _GLIBCXX_FS_FWD_H
ISO C++ entities toplevel namespace is std.
bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1433
constexpr _Iterator __base(_Iterator __it)