| [1166] | 1 | // Filesystem declarations -*- C++ -*-
|
|---|
| 2 |
|
|---|
| 3 | // Copyright (C) 2014-2021 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 | _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 | */
|
|---|
| 65 |
|
|---|
| 66 | class file_status;
|
|---|
| 67 | _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|---|
| 68 | class path;
|
|---|
| 69 | class filesystem_error;
|
|---|
| 70 | class directory_entry;
|
|---|
| 71 | class directory_iterator;
|
|---|
| 72 | class recursive_directory_iterator;
|
|---|
| 73 | _GLIBCXX_END_NAMESPACE_CXX11
|
|---|
| 74 |
|
|---|
| 75 | struct space_info
|
|---|
| 76 | {
|
|---|
| 77 | uintmax_t capacity;
|
|---|
| 78 | uintmax_t free;
|
|---|
| 79 | uintmax_t available;
|
|---|
| 80 | };
|
|---|
| 81 |
|
|---|
| 82 | enum class file_type : signed char {
|
|---|
| 83 | none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
|
|---|
| 84 | block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
|
|---|
| 85 | };
|
|---|
| 86 |
|
|---|
| 87 | /// Bitmask type
|
|---|
| 88 | enum class copy_options : unsigned short {
|
|---|
| 89 | none = 0,
|
|---|
| 90 | skip_existing = 1, overwrite_existing = 2, update_existing = 4,
|
|---|
| 91 | recursive = 8,
|
|---|
| 92 | copy_symlinks = 16, skip_symlinks = 32,
|
|---|
| 93 | directories_only = 64, create_symlinks = 128, create_hard_links = 256
|
|---|
| 94 | };
|
|---|
| 95 |
|
|---|
| 96 | constexpr copy_options
|
|---|
| 97 | operator&(copy_options __x, copy_options __y) noexcept
|
|---|
| 98 | {
|
|---|
| 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));
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | constexpr copy_options
|
|---|
| 105 | operator|(copy_options __x, copy_options __y) noexcept
|
|---|
| 106 | {
|
|---|
| 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));
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | constexpr copy_options
|
|---|
| 113 | operator^(copy_options __x, copy_options __y) noexcept
|
|---|
| 114 | {
|
|---|
| 115 | using __utype = typename std::underlying_type<copy_options>::type;
|
|---|
| 116 | return static_cast<copy_options>(
|
|---|
| 117 | static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | constexpr copy_options
|
|---|
| 121 | operator~(copy_options __x) noexcept
|
|---|
| 122 | {
|
|---|
| 123 | using __utype = typename std::underlying_type<copy_options>::type;
|
|---|
| 124 | return static_cast<copy_options>(~static_cast<__utype>(__x));
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | inline copy_options&
|
|---|
| 128 | operator&=(copy_options& __x, copy_options __y) noexcept
|
|---|
| 129 | { return __x = __x & __y; }
|
|---|
| 130 |
|
|---|
| 131 | inline copy_options&
|
|---|
| 132 | operator|=(copy_options& __x, copy_options __y) noexcept
|
|---|
| 133 | { return __x = __x | __y; }
|
|---|
| 134 |
|
|---|
| 135 | inline copy_options&
|
|---|
| 136 | operator^=(copy_options& __x, copy_options __y) noexcept
|
|---|
| 137 | { return __x = __x ^ __y; }
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 | /// Bitmask type
|
|---|
| 141 | enum class perms : unsigned {
|
|---|
| 142 | none = 0,
|
|---|
| 143 | owner_read = 0400,
|
|---|
| 144 | owner_write = 0200,
|
|---|
| 145 | owner_exec = 0100,
|
|---|
| 146 | owner_all = 0700,
|
|---|
| 147 | group_read = 040,
|
|---|
| 148 | group_write = 020,
|
|---|
| 149 | group_exec = 010,
|
|---|
| 150 | group_all = 070,
|
|---|
| 151 | others_read = 04,
|
|---|
| 152 | others_write = 02,
|
|---|
| 153 | others_exec = 01,
|
|---|
| 154 | others_all = 07,
|
|---|
| 155 | all = 0777,
|
|---|
| 156 | set_uid = 04000,
|
|---|
| 157 | set_gid = 02000,
|
|---|
| 158 | sticky_bit = 01000,
|
|---|
| 159 | mask = 07777,
|
|---|
| 160 | unknown = 0xFFFF,
|
|---|
| 161 | add_perms = 0x10000,
|
|---|
| 162 | remove_perms = 0x20000,
|
|---|
| 163 | symlink_nofollow = 0x40000
|
|---|
| 164 | };
|
|---|
| 165 |
|
|---|
| 166 | constexpr perms
|
|---|
| 167 | operator&(perms __x, perms __y) noexcept
|
|---|
| 168 | {
|
|---|
| 169 | using __utype = typename std::underlying_type<perms>::type;
|
|---|
| 170 | return static_cast<perms>(
|
|---|
| 171 | static_cast<__utype>(__x) & static_cast<__utype>(__y));
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | constexpr perms
|
|---|
| 175 | operator|(perms __x, perms __y) noexcept
|
|---|
| 176 | {
|
|---|
| 177 | using __utype = typename std::underlying_type<perms>::type;
|
|---|
| 178 | return static_cast<perms>(
|
|---|
| 179 | static_cast<__utype>(__x) | static_cast<__utype>(__y));
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 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 | constexpr perms
|
|---|
| 191 | operator~(perms __x) noexcept
|
|---|
| 192 | {
|
|---|
| 193 | using __utype = typename std::underlying_type<perms>::type;
|
|---|
| 194 | return static_cast<perms>(~static_cast<__utype>(__x));
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | inline perms&
|
|---|
| 198 | operator&=(perms& __x, perms __y) noexcept
|
|---|
| 199 | { return __x = __x & __y; }
|
|---|
| 200 |
|
|---|
| 201 | inline perms&
|
|---|
| 202 | operator|=(perms& __x, perms __y) noexcept
|
|---|
| 203 | { return __x = __x | __y; }
|
|---|
| 204 |
|
|---|
| 205 | inline perms&
|
|---|
| 206 | operator^=(perms& __x, perms __y) noexcept
|
|---|
| 207 | { return __x = __x ^ __y; }
|
|---|
| 208 |
|
|---|
| 209 | // Bitmask type
|
|---|
| 210 | enum class directory_options : unsigned char {
|
|---|
| 211 | none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
|
|---|
| 212 | };
|
|---|
| 213 |
|
|---|
| 214 | constexpr directory_options
|
|---|
| 215 | operator&(directory_options __x, directory_options __y) noexcept
|
|---|
| 216 | {
|
|---|
| 217 | using __utype = typename std::underlying_type<directory_options>::type;
|
|---|
| 218 | return static_cast<directory_options>(
|
|---|
| 219 | static_cast<__utype>(__x) & static_cast<__utype>(__y));
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | constexpr directory_options
|
|---|
| 223 | operator|(directory_options __x, directory_options __y) noexcept
|
|---|
| 224 | {
|
|---|
| 225 | using __utype = typename std::underlying_type<directory_options>::type;
|
|---|
| 226 | return static_cast<directory_options>(
|
|---|
| 227 | static_cast<__utype>(__x) | static_cast<__utype>(__y));
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | constexpr directory_options
|
|---|
| 231 | operator^(directory_options __x, directory_options __y) noexcept
|
|---|
| 232 | {
|
|---|
| 233 | using __utype = typename std::underlying_type<directory_options>::type;
|
|---|
| 234 | return static_cast<directory_options>(
|
|---|
| 235 | static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | constexpr directory_options
|
|---|
| 239 | operator~(directory_options __x) noexcept
|
|---|
| 240 | {
|
|---|
| 241 | using __utype = typename std::underlying_type<directory_options>::type;
|
|---|
| 242 | return static_cast<directory_options>(~static_cast<__utype>(__x));
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | inline directory_options&
|
|---|
| 246 | operator&=(directory_options& __x, directory_options __y) noexcept
|
|---|
| 247 | { return __x = __x & __y; }
|
|---|
| 248 |
|
|---|
| 249 | inline directory_options&
|
|---|
| 250 | operator|=(directory_options& __x, directory_options __y) noexcept
|
|---|
| 251 | { return __x = __x | __y; }
|
|---|
| 252 |
|
|---|
| 253 | inline directory_options&
|
|---|
| 254 | operator^=(directory_options& __x, directory_options __y) noexcept
|
|---|
| 255 | { return __x = __x ^ __y; }
|
|---|
| 256 |
|
|---|
| 257 | using file_time_type = std::chrono::system_clock::time_point;
|
|---|
| 258 |
|
|---|
| 259 | // operational functions
|
|---|
| 260 |
|
|---|
| 261 | void copy(const path& __from, const path& __to, copy_options __options);
|
|---|
| 262 | void copy(const path& __from, const path& __to, copy_options __options,
|
|---|
| 263 | error_code&) noexcept;
|
|---|
| 264 |
|
|---|
| 265 | bool copy_file(const path& __from, const path& __to, copy_options __option);
|
|---|
| 266 | bool copy_file(const path& __from, const path& __to, copy_options __option,
|
|---|
| 267 | error_code&) noexcept;
|
|---|
| 268 |
|
|---|
| 269 | path current_path();
|
|---|
| 270 |
|
|---|
| 271 | file_status status(const path&);
|
|---|
| 272 | file_status status(const path&, error_code&) noexcept;
|
|---|
| 273 |
|
|---|
| 274 | bool status_known(file_status) noexcept;
|
|---|
| 275 |
|
|---|
| 276 | file_status symlink_status(const path&);
|
|---|
| 277 | file_status symlink_status(const path&, error_code&) noexcept;
|
|---|
| 278 |
|
|---|
| 279 | bool is_regular_file(file_status) noexcept;
|
|---|
| 280 | bool is_symlink(file_status) noexcept;
|
|---|
| 281 |
|
|---|
| 282 | /// @} group filesystem-ts
|
|---|
| 283 | } // namespace v1
|
|---|
| 284 | } // namespace filesystem
|
|---|
| 285 | } // namespace experimental
|
|---|
| 286 |
|
|---|
| 287 | _GLIBCXX_END_NAMESPACE_VERSION
|
|---|
| 288 | } // namespace std
|
|---|
| 289 |
|
|---|
| 290 | #endif // C++11
|
|---|
| 291 |
|
|---|
| 292 | #endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H
|
|---|