libstdc++
experimental/bits/fs_fwd.h
Go to the documentation of this file.
1// Filesystem declarations -*- C++ -*-
2
3// Copyright (C) 2014-2026 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_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}
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>
39#include <bits/chrono.h>
40
41namespace std _GLIBCXX_VISIBILITY(default)
42{
43_GLIBCXX_BEGIN_NAMESPACE_VERSION
44
45namespace experimental
46{
47namespace filesystem
48{
49inline namespace v1
50{
51#if _GLIBCXX_USE_CXX11_ABI
52inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
53#endif
54
55 /**
56 * @defgroup filesystem-ts Filesystem TS
57 * @ingroup experimental
58 *
59 * Utilities for performing operations on file systems and their components,
60 * such as paths, regular files, and directories.
61 *
62 * ISO/IEC TS 18822:2015 C++ File System Technical Specification
63 *
64 * @since C++11
65 *
66 * @remark Link using `-lstdc++fs` to use these types and functions.
67 *
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
80 /// Information about free space on a disk
82 {
83 uintmax_t capacity;
84 uintmax_t free;
85 uintmax_t available;
86 };
87
88 /// Enumerated type representing the type of a file
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
94 /// Bitmask type controlling effects of `filesystem::copy`
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
103 /// @{
104 /// @relates copy_options
105 [[__nodiscard__]]
106 constexpr copy_options
107 operator&(copy_options __x, copy_options __y) noexcept
108 {
109 using __utype = typename std::underlying_type<copy_options>::type;
110 return static_cast<copy_options>(
111 static_cast<__utype>(__x) & static_cast<__utype>(__y));
112 }
113
114 [[__nodiscard__]]
115 constexpr copy_options
116 operator|(copy_options __x, copy_options __y) noexcept
117 {
118 using __utype = typename std::underlying_type<copy_options>::type;
119 return static_cast<copy_options>(
120 static_cast<__utype>(__x) | static_cast<__utype>(__y));
121 }
122
123 [[__nodiscard__]]
124 constexpr copy_options
125 operator^(copy_options __x, copy_options __y) noexcept
126 {
127 using __utype = typename std::underlying_type<copy_options>::type;
128 return static_cast<copy_options>(
129 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
130 }
131
132 [[__nodiscard__]]
133 constexpr copy_options
134 operator~(copy_options __x) noexcept
135 {
136 using __utype = typename std::underlying_type<copy_options>::type;
137 return static_cast<copy_options>(~static_cast<__utype>(__x));
138 }
139
140 inline copy_options&
141 operator&=(copy_options& __x, copy_options __y) noexcept
142 { return __x = __x & __y; }
143
144 inline copy_options&
145 operator|=(copy_options& __x, copy_options __y) noexcept
146 { return __x = __x | __y; }
147
148 inline copy_options&
149 operator^=(copy_options& __x, copy_options __y) noexcept
150 { return __x = __x ^ __y; }
151 /// @}
152
153 /// Bitmask type representing file access permissions
154#pragma GCC diagnostic push
155#pragma GCC diagnostic ignored "-Wdeprecated-octal-literal"
156 enum class perms : unsigned {
157 none = 0,
158 owner_read = 0400,
159 owner_write = 0200,
160 owner_exec = 0100,
161 owner_all = 0700,
162 group_read = 040,
163 group_write = 020,
164 group_exec = 010,
165 group_all = 070,
166 others_read = 04,
167 others_write = 02,
168 others_exec = 01,
169 others_all = 07,
170 all = 0777,
171 set_uid = 04000,
172 set_gid = 02000,
173 sticky_bit = 01000,
174 mask = 07777,
175 unknown = 0xFFFF,
176 add_perms = 0x10000,
177 remove_perms = 0x20000,
178 symlink_nofollow = 0x40000
179 };
180#pragma GCC diagnostic pop
181
182 /// @{
183 /// @relates std::experimental::filesystem::perms
184 [[__nodiscard__]]
185 constexpr perms
186 operator&(perms __x, perms __y) noexcept
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 [[__nodiscard__]]
194 constexpr perms
195 operator|(perms __x, perms __y) noexcept
196 {
197 using __utype = typename std::underlying_type<perms>::type;
198 return static_cast<perms>(
199 static_cast<__utype>(__x) | static_cast<__utype>(__y));
200 }
201
202 [[__nodiscard__]]
203 constexpr perms
204 operator^(perms __x, perms __y) noexcept
205 {
206 using __utype = typename std::underlying_type<perms>::type;
207 return static_cast<perms>(
208 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
209 }
210
211 [[__nodiscard__]]
212 constexpr perms
213 operator~(perms __x) noexcept
214 {
215 using __utype = typename std::underlying_type<perms>::type;
216 return static_cast<perms>(~static_cast<__utype>(__x));
217 }
218
219 inline perms&
220 operator&=(perms& __x, perms __y) noexcept
221 { return __x = __x & __y; }
222
223 inline perms&
224 operator|=(perms& __x, perms __y) noexcept
225 { return __x = __x | __y; }
226
227 inline perms&
228 operator^=(perms& __x, perms __y) noexcept
229 { return __x = __x ^ __y; }
230 /// @}
231
232 /// Bitmask type controlling directory iteration
233 enum class directory_options : unsigned char {
234 none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
235 };
236
237 /// @{
238 /// @relates directory_options
239 [[__nodiscard__]]
240 constexpr directory_options
241 operator&(directory_options __x, directory_options __y) noexcept
242 {
243 using __utype = typename std::underlying_type<directory_options>::type;
244 return static_cast<directory_options>(
245 static_cast<__utype>(__x) & static_cast<__utype>(__y));
246 }
247
248 [[__nodiscard__]]
249 constexpr directory_options
250 operator|(directory_options __x, directory_options __y) noexcept
251 {
252 using __utype = typename std::underlying_type<directory_options>::type;
253 return static_cast<directory_options>(
254 static_cast<__utype>(__x) | static_cast<__utype>(__y));
255 }
256
257 [[__nodiscard__]]
258 constexpr directory_options
259 operator^(directory_options __x, directory_options __y) noexcept
260 {
261 using __utype = typename std::underlying_type<directory_options>::type;
262 return static_cast<directory_options>(
263 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
264 }
265
266 [[__nodiscard__]]
267 constexpr directory_options
268 operator~(directory_options __x) noexcept
269 {
270 using __utype = typename std::underlying_type<directory_options>::type;
271 return static_cast<directory_options>(~static_cast<__utype>(__x));
272 }
273
274 inline directory_options&
275 operator&=(directory_options& __x, directory_options __y) noexcept
276 { return __x = __x & __y; }
277
278 inline directory_options&
279 operator|=(directory_options& __x, directory_options __y) noexcept
280 { return __x = __x | __y; }
281
282 inline directory_options&
283 operator^=(directory_options& __x, directory_options __y) noexcept
284 { return __x = __x ^ __y; }
285 /// @}
286
287 /// The type used for file timestamps
288 using file_time_type = std::chrono::system_clock::time_point;
289
290 // operational functions
291
292 void copy(const path& __from, const path& __to, copy_options __options);
293 void copy(const path& __from, const path& __to, copy_options __options,
294 error_code&) noexcept;
295
296 bool copy_file(const path& __from, const path& __to, copy_options __option);
297 bool copy_file(const path& __from, const path& __to, copy_options __option,
298 error_code&);
299
300 path current_path();
301
302 file_status status(const path&);
303 file_status status(const path&, error_code&) noexcept;
304
305 bool status_known(file_status) noexcept;
306
307 file_status symlink_status(const path&);
308 file_status symlink_status(const path&, error_code&) noexcept;
309
310 bool is_regular_file(file_status) noexcept;
311 bool is_symlink(file_status) noexcept;
312
313 /// @} group filesystem-ts
314} // namespace v1
315} // namespace filesystem
316} // namespace experimental
317
318_GLIBCXX_END_NAMESPACE_VERSION
319} // namespace std
320
321#endif // C++11
322
323#endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H
perms
Bitmask type representing file access permissions.
std::chrono::system_clock::time_point file_time_type
The type used for file timestamps.
file_type
Enumerated type representing the type of a file.
copy_options
Bitmask type controlling effects of filesystem::copy.
directory_options
Bitmask type controlling directory iteration.
ISO C++ entities toplevel namespace is std.
constexpr bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition bitset:1682
constexpr bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition bitset:1672
constexpr bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition bitset:1662
Namespace for features defined in ISO Technical Specifications.
The underlying type of an enum.
Definition type_traits:2728
Information about free space on a disk.
Exception type thrown by the Filesystem TS library.