1 // Filesystem declarations -*- C++ -*-
3 // Copyright (C) 2014-2015 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 experimental/filesystem
26 * This is a TS C++ Library header.
29 #ifndef _GLIBCXX_EXPERIMENTAL_FS_FWD_H
30 #define _GLIBCXX_EXPERIMENTAL_FS_FWD_H 1
32 #if __cplusplus < 201103L
33 # include <bits/c++0x_warning.h>
36 #include <system_error>
40 namespace std
_GLIBCXX_VISIBILITY(default)
42 namespace experimental
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 #if _GLIBCXX_USE_CXX11_ABI
51 inline namespace __cxx11
__attribute__((__abi_tag__ ("cxx11"))) { }
55 * @defgroup filesystem
56 * @ingroup experimental
58 * Utilities for performing operations on file systems and their components,
59 * such as paths, regular files, and directories.
65 _GLIBCXX_BEGIN_NAMESPACE_CXX11
67 class filesystem_error
;
68 class directory_entry
;
69 class directory_iterator
;
70 class recursive_directory_iterator
;
71 _GLIBCXX_END_NAMESPACE_CXX11
80 enum class file_type
: signed char {
81 none
= 0, not_found
= -1, regular
= 1, directory
= 2, symlink
= 3,
82 block
= 4, character
= 5, fifo
= 6, socket
= 7, unknown
= 8
86 enum class copy_options
: unsigned short {
88 skip_existing
= 1, overwrite_existing
= 2, update_existing
= 4,
90 copy_symlinks
= 16, skip_symlinks
= 32,
91 directories_only
= 64, create_symlinks
= 128, create_hard_links
= 256
94 constexpr copy_options
95 operator&(copy_options __x
, copy_options __y
)
97 using __utype
= typename
std::underlying_type
<copy_options
>::type
;
98 return static_cast<copy_options
>(
99 static_cast<__utype
>(__x
) & static_cast<__utype
>(__y
));
102 constexpr copy_options
103 operator|(copy_options __x
, copy_options __y
)
105 using __utype
= typename
std::underlying_type
<copy_options
>::type
;
106 return static_cast<copy_options
>(
107 static_cast<__utype
>(__x
) | static_cast<__utype
>(__y
));
110 constexpr copy_options
111 operator^(copy_options __x
, copy_options __y
)
113 using __utype
= typename
std::underlying_type
<copy_options
>::type
;
114 return static_cast<copy_options
>(
115 static_cast<__utype
>(__x
) ^ static_cast<__utype
>(__y
));
118 constexpr copy_options
119 operator~(copy_options __x
)
121 using __utype
= typename
std::underlying_type
<copy_options
>::type
;
122 return static_cast<copy_options
>(~static_cast<__utype
>(__x
));
126 operator&=(copy_options
& __x
, copy_options __y
)
127 { return __x
= __x
& __y
; }
130 operator|=(copy_options
& __x
, copy_options __y
)
131 { return __x
= __x
| __y
; }
134 operator^=(copy_options
& __x
, copy_options __y
)
135 { return __x
= __x
^ __y
; }
139 enum class perms
: unsigned {
160 remove_perms
= 0x20000,
161 resolve_symlinks
= 0x40000
165 operator&(perms __x
, perms __y
)
167 using __utype
= typename
std::underlying_type
<perms
>::type
;
168 return static_cast<perms
>(
169 static_cast<__utype
>(__x
) & static_cast<__utype
>(__y
));
173 operator|(perms __x
, perms __y
)
175 using __utype
= typename
std::underlying_type
<perms
>::type
;
176 return static_cast<perms
>(
177 static_cast<__utype
>(__x
) | static_cast<__utype
>(__y
));
181 operator^(perms __x
, perms __y
)
183 using __utype
= typename
std::underlying_type
<perms
>::type
;
184 return static_cast<perms
>(
185 static_cast<__utype
>(__x
) ^ static_cast<__utype
>(__y
));
191 using __utype
= typename
std::underlying_type
<perms
>::type
;
192 return static_cast<perms
>(~static_cast<__utype
>(__x
));
196 operator&=(perms
& __x
, perms __y
)
197 { return __x
= __x
& __y
; }
200 operator|=(perms
& __x
, perms __y
)
201 { return __x
= __x
| __y
; }
204 operator^=(perms
& __x
, perms __y
)
205 { return __x
= __x
^ __y
; }
208 enum class directory_options
: unsigned char {
209 none
= 0, follow_directory_symlink
= 1, skip_permission_denied
= 2
212 constexpr directory_options
213 operator&(directory_options __x
, directory_options __y
)
215 using __utype
= typename
std::underlying_type
<directory_options
>::type
;
216 return static_cast<directory_options
>(
217 static_cast<__utype
>(__x
) & static_cast<__utype
>(__y
));
220 constexpr directory_options
221 operator|(directory_options __x
, directory_options __y
)
223 using __utype
= typename
std::underlying_type
<directory_options
>::type
;
224 return static_cast<directory_options
>(
225 static_cast<__utype
>(__x
) | static_cast<__utype
>(__y
));
228 constexpr directory_options
229 operator^(directory_options __x
, directory_options __y
)
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
));
236 constexpr directory_options
237 operator~(directory_options __x
)
239 using __utype
= typename
std::underlying_type
<directory_options
>::type
;
240 return static_cast<directory_options
>(~static_cast<__utype
>(__x
));
243 inline directory_options
&
244 operator&=(directory_options
& __x
, directory_options __y
)
245 { return __x
= __x
& __y
; }
247 inline directory_options
&
248 operator|=(directory_options
& __x
, directory_options __y
)
249 { return __x
= __x
| __y
; }
251 inline directory_options
&
252 operator^=(directory_options
& __x
, directory_options __y
)
253 { return __x
= __x
^ __y
; }
255 typedef chrono::time_point
<chrono::system_clock
> file_time_type
;
257 // operational functions
259 void copy(const path
& __from
, const path
& __to
, copy_options __options
);
260 void copy(const path
& __from
, const path
& __to
, copy_options __options
,
261 error_code
&) noexcept
;
263 bool copy_file(const path
& __from
, const path
& __to
, copy_options __option
);
264 bool copy_file(const path
& __from
, const path
& __to
, copy_options __option
,
265 error_code
&) noexcept
;
269 file_status
status(const path
&);
270 file_status
status(const path
&, error_code
&) noexcept
;
272 bool status_known(file_status
) noexcept
;
274 file_status
symlink_status(const path
&);
275 file_status
symlink_status(const path
&, error_code
&) noexcept
;
277 bool is_regular_file(file_status
) noexcept
;
278 bool is_symlink(file_status
) noexcept
;
280 // @} group filesystem
281 _GLIBCXX_END_NAMESPACE_VERSION
283 } // namespace filesystem
284 } // namespace experimental
289 #endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H