RISC-V: Add --specs=nosys.specs support.
[official-gcc.git] / libstdc++-v3 / include / bits / fs_fwd.h
blob27314ce1ffa2ca62b5e328d9bb416f58df37138b
1 // Filesystem declarations -*- C++ -*-
3 // Copyright (C) 2014-2018 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 <chrono>
39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 namespace filesystem
45 #if _GLIBCXX_USE_CXX11_ABI
46 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
47 #endif
49 /**
50 * @defgroup filesystem Filesystem
52 * Utilities for performing operations on file systems and their components,
53 * such as paths, regular files, and directories.
55 * @{
58 class file_status;
59 _GLIBCXX_BEGIN_NAMESPACE_CXX11
60 class path;
61 class filesystem_error;
62 class directory_entry;
63 class directory_iterator;
64 class recursive_directory_iterator;
65 _GLIBCXX_END_NAMESPACE_CXX11
67 struct space_info
69 uintmax_t capacity;
70 uintmax_t free;
71 uintmax_t available;
74 enum class file_type : signed char {
75 none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
76 block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
79 /// Bitmask type
80 enum class copy_options : unsigned short {
81 none = 0,
82 skip_existing = 1, overwrite_existing = 2, update_existing = 4,
83 recursive = 8,
84 copy_symlinks = 16, skip_symlinks = 32,
85 directories_only = 64, create_symlinks = 128, create_hard_links = 256
88 constexpr copy_options
89 operator&(copy_options __x, copy_options __y) noexcept
91 using __utype = typename std::underlying_type<copy_options>::type;
92 return static_cast<copy_options>(
93 static_cast<__utype>(__x) & static_cast<__utype>(__y));
96 constexpr copy_options
97 operator|(copy_options __x, copy_options __y) noexcept
99 using __utype = typename std::underlying_type<copy_options>::type;
100 return static_cast<copy_options>(
101 static_cast<__utype>(__x) | static_cast<__utype>(__y));
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 constexpr copy_options
113 operator~(copy_options __x) noexcept
115 using __utype = typename std::underlying_type<copy_options>::type;
116 return static_cast<copy_options>(~static_cast<__utype>(__x));
119 inline copy_options&
120 operator&=(copy_options& __x, copy_options __y) noexcept
121 { return __x = __x & __y; }
123 inline copy_options&
124 operator|=(copy_options& __x, copy_options __y) noexcept
125 { return __x = __x | __y; }
127 inline copy_options&
128 operator^=(copy_options& __x, copy_options __y) noexcept
129 { return __x = __x ^ __y; }
132 /// Bitmask type
133 enum class perms : unsigned {
134 none = 0,
135 owner_read = 0400,
136 owner_write = 0200,
137 owner_exec = 0100,
138 owner_all = 0700,
139 group_read = 040,
140 group_write = 020,
141 group_exec = 010,
142 group_all = 070,
143 others_read = 04,
144 others_write = 02,
145 others_exec = 01,
146 others_all = 07,
147 all = 0777,
148 set_uid = 04000,
149 set_gid = 02000,
150 sticky_bit = 01000,
151 mask = 07777,
152 unknown = 0xFFFF,
155 constexpr perms
156 operator&(perms __x, perms __y) noexcept
158 using __utype = typename std::underlying_type<perms>::type;
159 return static_cast<perms>(
160 static_cast<__utype>(__x) & static_cast<__utype>(__y));
163 constexpr perms
164 operator|(perms __x, perms __y) noexcept
166 using __utype = typename std::underlying_type<perms>::type;
167 return static_cast<perms>(
168 static_cast<__utype>(__x) | static_cast<__utype>(__y));
171 constexpr perms
172 operator^(perms __x, perms __y) noexcept
174 using __utype = typename std::underlying_type<perms>::type;
175 return static_cast<perms>(
176 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
179 constexpr perms
180 operator~(perms __x) noexcept
182 using __utype = typename std::underlying_type<perms>::type;
183 return static_cast<perms>(~static_cast<__utype>(__x));
186 inline perms&
187 operator&=(perms& __x, perms __y) noexcept
188 { return __x = __x & __y; }
190 inline perms&
191 operator|=(perms& __x, perms __y) noexcept
192 { return __x = __x | __y; }
194 inline perms&
195 operator^=(perms& __x, perms __y) noexcept
196 { return __x = __x ^ __y; }
198 /// Bitmask type
199 enum class perm_options : unsigned {
200 replace = 0x1,
201 add = 0x2,
202 remove = 0x4,
203 nofollow = 0x8
206 constexpr perm_options
207 operator&(perm_options __x, perm_options __y) noexcept
209 using __utype = typename std::underlying_type<perm_options>::type;
210 return static_cast<perm_options>(
211 static_cast<__utype>(__x) & static_cast<__utype>(__y));
214 constexpr perm_options
215 operator|(perm_options __x, perm_options __y) noexcept
217 using __utype = typename std::underlying_type<perm_options>::type;
218 return static_cast<perm_options>(
219 static_cast<__utype>(__x) | static_cast<__utype>(__y));
222 constexpr perm_options
223 operator^(perm_options __x, perm_options __y) noexcept
225 using __utype = typename std::underlying_type<perm_options>::type;
226 return static_cast<perm_options>(
227 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
230 constexpr perm_options
231 operator~(perm_options __x) noexcept
233 using __utype = typename std::underlying_type<perm_options>::type;
234 return static_cast<perm_options>(~static_cast<__utype>(__x));
237 inline perm_options&
238 operator&=(perm_options& __x, perm_options __y) noexcept
239 { return __x = __x & __y; }
241 inline perm_options&
242 operator|=(perm_options& __x, perm_options __y) noexcept
243 { return __x = __x | __y; }
245 inline perm_options&
246 operator^=(perm_options& __x, perm_options __y) noexcept
247 { return __x = __x ^ __y; }
249 // Bitmask type
250 enum class directory_options : unsigned char {
251 none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
254 constexpr directory_options
255 operator&(directory_options __x, directory_options __y) noexcept
257 using __utype = typename std::underlying_type<directory_options>::type;
258 return static_cast<directory_options>(
259 static_cast<__utype>(__x) & static_cast<__utype>(__y));
262 constexpr directory_options
263 operator|(directory_options __x, directory_options __y) noexcept
265 using __utype = typename std::underlying_type<directory_options>::type;
266 return static_cast<directory_options>(
267 static_cast<__utype>(__x) | static_cast<__utype>(__y));
270 constexpr directory_options
271 operator^(directory_options __x, directory_options __y) noexcept
273 using __utype = typename std::underlying_type<directory_options>::type;
274 return static_cast<directory_options>(
275 static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
278 constexpr directory_options
279 operator~(directory_options __x) noexcept
281 using __utype = typename std::underlying_type<directory_options>::type;
282 return static_cast<directory_options>(~static_cast<__utype>(__x));
285 inline directory_options&
286 operator&=(directory_options& __x, directory_options __y) noexcept
287 { return __x = __x & __y; }
289 inline directory_options&
290 operator|=(directory_options& __x, directory_options __y) noexcept
291 { return __x = __x | __y; }
293 inline directory_options&
294 operator^=(directory_options& __x, directory_options __y) noexcept
295 { return __x = __x ^ __y; }
297 using file_time_type = std::chrono::system_clock::time_point;
299 // operational functions
301 void copy(const path& __from, const path& __to, copy_options __options);
302 void copy(const path& __from, const path& __to, copy_options __options,
303 error_code&);
305 bool copy_file(const path& __from, const path& __to, copy_options __option);
306 bool copy_file(const path& __from, const path& __to, copy_options __option,
307 error_code&);
309 path current_path();
311 bool exists(file_status) noexcept;
313 bool is_other(file_status) noexcept;
315 uintmax_t file_size(const path&);
316 uintmax_t file_size(const path&, error_code&) noexcept;
317 uintmax_t hard_link_count(const path&);
318 uintmax_t hard_link_count(const path&, error_code&) noexcept;
319 file_time_type last_write_time(const path&);
320 file_time_type last_write_time(const path&, error_code&) noexcept;
322 void permissions(const path&, perms, perm_options, error_code&) noexcept;
324 path proximate(const path& __p, const path& __base, error_code& __ec);
325 path proximate(const path& __p, const path& __base, error_code& __ec);
327 path relative(const path& __p, const path& __base, error_code& __ec);
329 file_status status(const path&);
330 file_status status(const path&, error_code&) noexcept;
332 bool status_known(file_status) noexcept;
334 file_status symlink_status(const path&);
335 file_status symlink_status(const path&, error_code&) noexcept;
337 bool is_regular_file(file_status) noexcept;
338 bool is_symlink(file_status) noexcept;
340 // @} group filesystem
341 } // namespace filesystem
343 _GLIBCXX_END_NAMESPACE_VERSION
344 } // namespace std
346 #endif // C++17
348 #endif // _GLIBCXX_FS_FWD_H