1 // Filesystem declarations -*- C++ -*-
3 // Copyright (C) 2014-2018 Free Software Foundation, Inc.
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)
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>
39 namespace std
_GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 #if _GLIBCXX_USE_CXX11_ABI
46 inline namespace __cxx11
__attribute__((__abi_tag__ ("cxx11"))) { }
50 * @defgroup filesystem Filesystem
52 * Utilities for performing operations on file systems and their components,
53 * such as paths, regular files, and directories.
59 _GLIBCXX_BEGIN_NAMESPACE_CXX11
61 class filesystem_error
;
62 class directory_entry
;
63 class directory_iterator
;
64 class recursive_directory_iterator
;
65 _GLIBCXX_END_NAMESPACE_CXX11
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
80 enum class copy_options
: unsigned short {
82 skip_existing
= 1, overwrite_existing
= 2, update_existing
= 4,
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
));
120 operator&=(copy_options
& __x
, copy_options __y
) noexcept
121 { return __x
= __x
& __y
; }
124 operator|=(copy_options
& __x
, copy_options __y
) noexcept
125 { return __x
= __x
| __y
; }
128 operator^=(copy_options
& __x
, copy_options __y
) noexcept
129 { return __x
= __x
^ __y
; }
133 enum class perms
: unsigned {
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
));
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
));
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
));
180 operator~(perms __x
) noexcept
182 using __utype
= typename
std::underlying_type
<perms
>::type
;
183 return static_cast<perms
>(~static_cast<__utype
>(__x
));
187 operator&=(perms
& __x
, perms __y
) noexcept
188 { return __x
= __x
& __y
; }
191 operator|=(perms
& __x
, perms __y
) noexcept
192 { return __x
= __x
| __y
; }
195 operator^=(perms
& __x
, perms __y
) noexcept
196 { return __x
= __x
^ __y
; }
199 enum class perm_options
: unsigned {
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
));
238 operator&=(perm_options
& __x
, perm_options __y
) noexcept
239 { return __x
= __x
& __y
; }
242 operator|=(perm_options
& __x
, perm_options __y
) noexcept
243 { return __x
= __x
| __y
; }
246 operator^=(perm_options
& __x
, perm_options __y
) noexcept
247 { return __x
= __x
^ __y
; }
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
,
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
,
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
348 #endif // _GLIBCXX_FS_FWD_H