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