libstdc++
fs_fwd.h
Go to the documentation of this file.
1 // Filesystem declarations -*- C++ -*-
2 
3 // Copyright (C) 2014-2017 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 <chrono>
40 
41 namespace std _GLIBCXX_VISIBILITY(default)
42 {
43 namespace experimental
44 {
45 namespace filesystem
46 {
47 inline namespace v1
48 {
49 #if _GLIBCXX_INLINE_VERSION
50 inline namespace __7 { }
51 #endif
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
53 
54 #if _GLIBCXX_USE_CXX11_ABI
55 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
56 #endif
57 
58  /**
59  * @defgroup filesystem Filesystem
60  * @ingroup experimental
61  *
62  * Utilities for performing operations on file systems and their components,
63  * such as paths, regular files, and directories.
64  *
65  * @{
66  */
67 
68  class file_status;
69 _GLIBCXX_BEGIN_NAMESPACE_CXX11
70  class path;
71  class filesystem_error;
72  class directory_entry;
73  class directory_iterator;
74  class recursive_directory_iterator;
75 _GLIBCXX_END_NAMESPACE_CXX11
76 
77  struct space_info
78  {
79  uintmax_t capacity;
80  uintmax_t free;
81  uintmax_t available;
82  };
83 
84  enum class file_type : signed char {
85  none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
86  block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
87  };
88 
89  /// Bitmask type
90  enum class copy_options : unsigned short {
91  none = 0,
92  skip_existing = 1, overwrite_existing = 2, update_existing = 4,
93  recursive = 8,
94  copy_symlinks = 16, skip_symlinks = 32,
95  directories_only = 64, create_symlinks = 128, create_hard_links = 256
96  };
97 
98  constexpr copy_options
99  operator&(copy_options __x, copy_options __y) noexcept
100  {
101  using __utype = typename std::underlying_type<copy_options>::type;
102  return static_cast<copy_options>(
103  static_cast<__utype>(__x) & static_cast<__utype>(__y));
104  }
105 
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  constexpr copy_options
115  operator^(copy_options __x, copy_options __y) noexcept
116  {
117  using __utype = typename std::underlying_type<copy_options>::type;
118  return static_cast<copy_options>(
119  static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
120  }
121 
122  constexpr copy_options
123  operator~(copy_options __x) noexcept
124  {
125  using __utype = typename std::underlying_type<copy_options>::type;
126  return static_cast<copy_options>(~static_cast<__utype>(__x));
127  }
128 
129  inline copy_options&
130  operator&=(copy_options& __x, copy_options __y) noexcept
131  { return __x = __x & __y; }
132 
133  inline copy_options&
134  operator|=(copy_options& __x, copy_options __y) noexcept
135  { return __x = __x | __y; }
136 
137  inline copy_options&
138  operator^=(copy_options& __x, copy_options __y) noexcept
139  { return __x = __x ^ __y; }
140 
141 
142  /// Bitmask type
143  enum class perms : unsigned {
144  none = 0,
145  owner_read = 0400,
146  owner_write = 0200,
147  owner_exec = 0100,
148  owner_all = 0700,
149  group_read = 040,
150  group_write = 020,
151  group_exec = 010,
152  group_all = 070,
153  others_read = 04,
154  others_write = 02,
155  others_exec = 01,
156  others_all = 07,
157  all = 0777,
158  set_uid = 04000,
159  set_gid = 02000,
160  sticky_bit = 01000,
161  mask = 07777,
162  unknown = 0xFFFF,
163  add_perms = 0x10000,
164  remove_perms = 0x20000,
165  symlink_nofollow = 0x40000
166  };
167 
168  constexpr perms
169  operator&(perms __x, perms __y) noexcept
170  {
171  using __utype = typename std::underlying_type<perms>::type;
172  return static_cast<perms>(
173  static_cast<__utype>(__x) & static_cast<__utype>(__y));
174  }
175 
176  constexpr perms
177  operator|(perms __x, perms __y) noexcept
178  {
179  using __utype = typename std::underlying_type<perms>::type;
180  return static_cast<perms>(
181  static_cast<__utype>(__x) | static_cast<__utype>(__y));
182  }
183 
184  constexpr perms
185  operator^(perms __x, perms __y) noexcept
186  {
187  using __utype = typename std::underlying_type<perms>::type;
188  return static_cast<perms>(
189  static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
190  }
191 
192  constexpr perms
193  operator~(perms __x) noexcept
194  {
195  using __utype = typename std::underlying_type<perms>::type;
196  return static_cast<perms>(~static_cast<__utype>(__x));
197  }
198 
199  inline perms&
200  operator&=(perms& __x, perms __y) noexcept
201  { return __x = __x & __y; }
202 
203  inline perms&
204  operator|=(perms& __x, perms __y) noexcept
205  { return __x = __x | __y; }
206 
207  inline perms&
208  operator^=(perms& __x, perms __y) noexcept
209  { return __x = __x ^ __y; }
210 
211  // Bitmask type
212  enum class directory_options : unsigned char {
213  none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
214  };
215 
216  constexpr directory_options
217  operator&(directory_options __x, directory_options __y) noexcept
218  {
219  using __utype = typename std::underlying_type<directory_options>::type;
220  return static_cast<directory_options>(
221  static_cast<__utype>(__x) & static_cast<__utype>(__y));
222  }
223 
224  constexpr directory_options
225  operator|(directory_options __x, directory_options __y) noexcept
226  {
227  using __utype = typename std::underlying_type<directory_options>::type;
228  return static_cast<directory_options>(
229  static_cast<__utype>(__x) | static_cast<__utype>(__y));
230  }
231 
232  constexpr directory_options
233  operator^(directory_options __x, directory_options __y) noexcept
234  {
235  using __utype = typename std::underlying_type<directory_options>::type;
236  return static_cast<directory_options>(
237  static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
238  }
239 
240  constexpr directory_options
241  operator~(directory_options __x) noexcept
242  {
243  using __utype = typename std::underlying_type<directory_options>::type;
244  return static_cast<directory_options>(~static_cast<__utype>(__x));
245  }
246 
247  inline directory_options&
248  operator&=(directory_options& __x, directory_options __y) noexcept
249  { return __x = __x & __y; }
250 
251  inline directory_options&
252  operator|=(directory_options& __x, directory_options __y) noexcept
253  { return __x = __x | __y; }
254 
255  inline directory_options&
256  operator^=(directory_options& __x, directory_options __y) noexcept
257  { return __x = __x ^ __y; }
258 
259  using file_time_type = std::chrono::system_clock::time_point;
260 
261  // operational functions
262 
263  void copy(const path& __from, const path& __to, copy_options __options);
264  void copy(const path& __from, const path& __to, copy_options __options,
265  error_code&) noexcept;
266 
267  bool copy_file(const path& __from, const path& __to, copy_options __option);
268  bool copy_file(const path& __from, const path& __to, copy_options __option,
269  error_code&) noexcept;
270 
271  path current_path();
272 
273  file_status status(const path&);
274  file_status status(const path&, error_code&) noexcept;
275 
276  bool status_known(file_status) noexcept;
277 
278  file_status symlink_status(const path&);
279  file_status symlink_status(const path&, error_code&) noexcept;
280 
281  bool is_regular_file(file_status) noexcept;
282  bool is_symlink(file_status) noexcept;
283 
284  // @} group filesystem
285 _GLIBCXX_END_NAMESPACE_VERSION
286 } // namespace v1
287 } // namespace filesystem
288 } // namespace experimental
289 } // namespace std
290 
291 #endif // C++11
292 
293 #endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H
bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1443
error_code
Definition: system_error:146
ISO C++ entities toplevel namespace is std.
bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1434
bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1425