2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / libstdc++-v3 / include / experimental / fs_fwd.h
bloba5ed2c5de0ef285aea2c1a8e554bc1d6ecda3ce4
1 // Filesystem declarations -*- C++ -*-
3 // Copyright (C) 2014-2015 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 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>
34 #else
36 #include <system_error>
37 #include <cstdint>
38 #include <chrono>
40 namespace std _GLIBCXX_VISIBILITY(default)
42 namespace experimental
44 namespace filesystem
46 inline namespace v1
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 #if _GLIBCXX_USE_CXX11_ABI
51 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
52 #endif
54 /**
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.
61 * @{
64 class file_status;
65 _GLIBCXX_BEGIN_NAMESPACE_CXX11
66 class path;
67 class filesystem_error;
68 class directory_entry;
69 class directory_iterator;
70 class recursive_directory_iterator;
71 _GLIBCXX_END_NAMESPACE_CXX11
73 struct space_info
75 uintmax_t capacity;
76 uintmax_t free;
77 uintmax_t available;
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
85 /// Bitmask type
86 enum class copy_options : unsigned short {
87 none = 0,
88 skip_existing = 1, overwrite_existing = 2, update_existing = 4,
89 recursive = 8,
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));
125 inline copy_options&
126 operator&=(copy_options& __x, copy_options __y)
127 { return __x = __x & __y; }
129 inline copy_options&
130 operator|=(copy_options& __x, copy_options __y)
131 { return __x = __x | __y; }
133 inline copy_options&
134 operator^=(copy_options& __x, copy_options __y)
135 { return __x = __x ^ __y; }
138 /// Bitmask type
139 enum class perms : unsigned {
140 none = 0,
141 owner_read = 0400,
142 owner_write = 0200,
143 owner_exec = 0100,
144 owner_all = 0700,
145 group_read = 040,
146 group_write = 020,
147 group_exec = 010,
148 group_all = 070,
149 others_read = 04,
150 others_write = 02,
151 others_exec = 01,
152 others_all = 07,
153 all = 0777,
154 set_uid = 04000,
155 set_gid = 02000,
156 sticky_bit = 01000,
157 mask = 07777,
158 unknown = 0xFFFF,
159 add_perms = 0x10000,
160 remove_perms = 0x20000,
161 resolve_symlinks = 0x40000
164 constexpr perms
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));
172 constexpr perms
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));
180 constexpr perms
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));
188 constexpr perms
189 operator~(perms __x)
191 using __utype = typename std::underlying_type<perms>::type;
192 return static_cast<perms>(~static_cast<__utype>(__x));
195 inline perms&
196 operator&=(perms& __x, perms __y)
197 { return __x = __x & __y; }
199 inline perms&
200 operator|=(perms& __x, perms __y)
201 { return __x = __x | __y; }
203 inline perms&
204 operator^=(perms& __x, perms __y)
205 { return __x = __x ^ __y; }
207 // Bitmask type
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;
267 path current_path();
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
282 } // namespace v1
283 } // namespace filesystem
284 } // namespace experimental
285 } // namespace std
287 #endif // C++11
289 #endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H