| 1 | // boost/filesystem/operations.hpp ---------------------------------------------------// |
| 2 | |
| 3 | // Copyright Beman Dawes 2002-2009 |
| 4 | // Copyright Jan Langer 2002 |
| 5 | // Copyright Dietmar Kuehl 2001 |
| 6 | // Copyright Vladimir Prus 2002 |
| 7 | // Copyright Andrey Semashev 2020-2024 |
| 8 | |
| 9 | // Distributed under the Boost Software License, Version 1.0. |
| 10 | // See http://www.boost.org/LICENSE_1_0.txt |
| 11 | |
| 12 | // Library home page: http://www.boost.org/libs/filesystem |
| 13 | |
| 14 | //--------------------------------------------------------------------------------------// |
| 15 | |
| 16 | #ifndef BOOST_FILESYSTEM_OPERATIONS_HPP |
| 17 | #define BOOST_FILESYSTEM_OPERATIONS_HPP |
| 18 | |
| 19 | #include <boost/filesystem/config.hpp> |
| 20 | #include <boost/filesystem/path.hpp> |
| 21 | #include <boost/filesystem/file_status.hpp> |
| 22 | |
| 23 | #include <boost/detail/bitmask.hpp> |
| 24 | #include <boost/system/error_code.hpp> |
| 25 | #include <boost/cstdint.hpp> |
| 26 | #include <ctime> |
| 27 | #include <string> |
| 28 | |
| 29 | #include <boost/filesystem/detail/header.hpp> // must be the last #include |
| 30 | |
| 31 | //--------------------------------------------------------------------------------------// |
| 32 | |
| 33 | namespace boost { |
| 34 | namespace filesystem { |
| 35 | |
| 36 | struct space_info |
| 37 | { |
| 38 | // all values are byte counts |
| 39 | boost::uintmax_t capacity; |
| 40 | boost::uintmax_t free; // <= capacity |
| 41 | boost::uintmax_t available; // <= free |
| 42 | }; |
| 43 | |
| 44 | enum class copy_options : unsigned int |
| 45 | { |
| 46 | none = 0u, // Default. For copy_file: error if the target file exists. For copy: do not recurse, follow symlinks, copy file contents. |
| 47 | |
| 48 | // copy_file options: |
| 49 | skip_existing = 1u, // Don't overwrite the existing target file, don't report an error |
| 50 | overwrite_existing = 1u << 1u, // Overwrite existing file |
| 51 | update_existing = 1u << 2u, // Overwrite existing file if its last write time is older than the replacement file |
| 52 | synchronize_data = 1u << 3u, // Flush all buffered data written to the target file to permanent storage |
| 53 | synchronize = 1u << 4u, // Flush all buffered data and attributes written to the target file to permanent storage |
| 54 | ignore_attribute_errors = 1u << 5u, // Ignore errors of copying file attributes |
| 55 | |
| 56 | // copy options: |
| 57 | recursive = 1u << 8u, // Recurse into sub-directories |
| 58 | copy_symlinks = 1u << 9u, // Copy symlinks as symlinks instead of copying the referenced file |
| 59 | skip_symlinks = 1u << 10u, // Don't copy symlinks |
| 60 | directories_only = 1u << 11u, // Only copy directory structure, do not copy non-directory files |
| 61 | create_symlinks = 1u << 12u, // Create symlinks instead of copying files |
| 62 | create_hard_links = 1u << 13u, // Create hard links instead of copying files |
| 63 | _detail_recursing = 1u << 14u // Internal use only, do not use |
| 64 | }; |
| 65 | |
| 66 | BOOST_BITMASK(copy_options) |
| 67 | |
| 68 | //--------------------------------------------------------------------------------------// |
| 69 | // implementation details // |
| 70 | //--------------------------------------------------------------------------------------// |
| 71 | |
| 72 | namespace detail { |
| 73 | |
| 74 | BOOST_FILESYSTEM_DECL |
| 75 | path absolute_v3(path const& p, path const& base, system::error_code* ec = nullptr); |
| 76 | BOOST_FILESYSTEM_DECL |
| 77 | path absolute_v4(path const& p, path const& base, system::error_code* ec = nullptr); |
| 78 | BOOST_FILESYSTEM_DECL |
| 79 | file_status status(path const& p, system::error_code* ec = nullptr); |
| 80 | BOOST_FILESYSTEM_DECL |
| 81 | file_status symlink_status(path const& p, system::error_code* ec = nullptr); |
| 82 | BOOST_FILESYSTEM_DECL |
| 83 | bool is_empty(path const& p, system::error_code* ec = nullptr); |
| 84 | BOOST_FILESYSTEM_DECL |
| 85 | path initial_path(system::error_code* ec = nullptr); |
| 86 | BOOST_FILESYSTEM_DECL |
| 87 | path canonical_v3(path const& p, path const& base, system::error_code* ec = nullptr); |
| 88 | BOOST_FILESYSTEM_DECL |
| 89 | path canonical_v4(path const& p, path const& base, system::error_code* ec = nullptr); |
| 90 | BOOST_FILESYSTEM_DECL |
| 91 | void copy(path const& from, path const& to, copy_options options, system::error_code* ec = nullptr); |
| 92 | BOOST_FILESYSTEM_DECL |
| 93 | bool copy_file(path const& from, path const& to, copy_options options, system::error_code* ec = nullptr); |
| 94 | BOOST_FILESYSTEM_DECL |
| 95 | void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code* ec = nullptr); |
| 96 | BOOST_FILESYSTEM_DECL |
| 97 | bool create_directories(path const& p, system::error_code* ec = nullptr); |
| 98 | BOOST_FILESYSTEM_DECL |
| 99 | bool create_directory(path const& p, const path* existing, system::error_code* ec = nullptr); |
| 100 | BOOST_FILESYSTEM_DECL |
| 101 | void create_directory_symlink(path const& to, path const& from, system::error_code* ec = nullptr); |
| 102 | BOOST_FILESYSTEM_DECL |
| 103 | void create_hard_link(path const& to, path const& from, system::error_code* ec = nullptr); |
| 104 | BOOST_FILESYSTEM_DECL |
| 105 | void create_symlink(path const& to, path const& from, system::error_code* ec = nullptr); |
| 106 | BOOST_FILESYSTEM_DECL |
| 107 | path current_path(system::error_code* ec = nullptr); |
| 108 | BOOST_FILESYSTEM_DECL |
| 109 | void current_path(path const& p, system::error_code* ec = nullptr); |
| 110 | BOOST_FILESYSTEM_DECL |
| 111 | bool equivalent_v3(path const& p1, path const& p2, system::error_code* ec = nullptr); |
| 112 | BOOST_FILESYSTEM_DECL |
| 113 | bool equivalent_v4(path const& p1, path const& p2, system::error_code* ec = nullptr); |
| 114 | BOOST_FILESYSTEM_DECL |
| 115 | boost::uintmax_t file_size(path const& p, system::error_code* ec = nullptr); |
| 116 | BOOST_FILESYSTEM_DECL |
| 117 | boost::uintmax_t hard_link_count(path const& p, system::error_code* ec = nullptr); |
| 118 | BOOST_FILESYSTEM_DECL |
| 119 | std::time_t creation_time(path const& p, system::error_code* ec = nullptr); |
| 120 | BOOST_FILESYSTEM_DECL |
| 121 | std::time_t last_write_time(path const& p, system::error_code* ec = nullptr); |
| 122 | BOOST_FILESYSTEM_DECL |
| 123 | void last_write_time(path const& p, const std::time_t new_time, system::error_code* ec = nullptr); |
| 124 | BOOST_FILESYSTEM_DECL |
| 125 | void permissions(path const& p, perms prms, system::error_code* ec = nullptr); |
| 126 | BOOST_FILESYSTEM_DECL |
| 127 | path read_symlink(path const& p, system::error_code* ec = nullptr); |
| 128 | BOOST_FILESYSTEM_DECL |
| 129 | path relative(path const& p, path const& base, system::error_code* ec = nullptr); |
| 130 | BOOST_FILESYSTEM_DECL |
| 131 | bool remove(path const& p, system::error_code* ec = nullptr); |
| 132 | BOOST_FILESYSTEM_DECL |
| 133 | boost::uintmax_t remove_all(path const& p, system::error_code* ec = nullptr); |
| 134 | BOOST_FILESYSTEM_DECL |
| 135 | void rename(path const& old_p, path const& new_p, system::error_code* ec = nullptr); |
| 136 | BOOST_FILESYSTEM_DECL |
| 137 | void resize_file(path const& p, uintmax_t size, system::error_code* ec = nullptr); |
| 138 | BOOST_FILESYSTEM_DECL |
| 139 | space_info space(path const& p, system::error_code* ec = nullptr); |
| 140 | BOOST_FILESYSTEM_DECL |
| 141 | path system_complete(path const& p, system::error_code* ec = nullptr); |
| 142 | BOOST_FILESYSTEM_DECL |
| 143 | path temp_directory_path(system::error_code* ec = nullptr); |
| 144 | BOOST_FILESYSTEM_DECL |
| 145 | path unique_path(path const& p, system::error_code* ec = nullptr); |
| 146 | BOOST_FILESYSTEM_DECL |
| 147 | path weakly_canonical_v3(path const& p, path const& base, system::error_code* ec = nullptr); |
| 148 | BOOST_FILESYSTEM_DECL |
| 149 | path weakly_canonical_v4(path const& p, path const& base, system::error_code* ec = nullptr); |
| 150 | |
| 151 | } // namespace detail |
| 152 | |
| 153 | //--------------------------------------------------------------------------------------// |
| 154 | // // |
| 155 | // status query functions // |
| 156 | // // |
| 157 | //--------------------------------------------------------------------------------------// |
| 158 | |
| 159 | inline file_status status(path const& p) |
| 160 | { |
| 161 | return detail::status(p); |
| 162 | } |
| 163 | |
| 164 | inline file_status status(path const& p, system::error_code& ec) noexcept |
| 165 | { |
| 166 | return detail::status(p, ec: &ec); |
| 167 | } |
| 168 | |
| 169 | inline file_status symlink_status(path const& p) |
| 170 | { |
| 171 | return detail::symlink_status(p); |
| 172 | } |
| 173 | |
| 174 | inline file_status symlink_status(path const& p, system::error_code& ec) noexcept |
| 175 | { |
| 176 | return detail::symlink_status(p, ec: &ec); |
| 177 | } |
| 178 | |
| 179 | inline bool exists(path const& p) |
| 180 | { |
| 181 | return filesystem::exists(f: detail::status(p)); |
| 182 | } |
| 183 | |
| 184 | inline bool exists(path const& p, system::error_code& ec) noexcept |
| 185 | { |
| 186 | return filesystem::exists(f: detail::status(p, ec: &ec)); |
| 187 | } |
| 188 | |
| 189 | inline bool is_regular_file(path const& p) |
| 190 | { |
| 191 | return filesystem::is_regular_file(f: detail::status(p)); |
| 192 | } |
| 193 | |
| 194 | inline bool is_regular_file(path const& p, system::error_code& ec) noexcept |
| 195 | { |
| 196 | return filesystem::is_regular_file(f: detail::status(p, ec: &ec)); |
| 197 | } |
| 198 | |
| 199 | inline bool is_directory(path const& p) |
| 200 | { |
| 201 | return filesystem::is_directory(f: detail::status(p)); |
| 202 | } |
| 203 | |
| 204 | inline bool is_directory(path const& p, system::error_code& ec) noexcept |
| 205 | { |
| 206 | return filesystem::is_directory(f: detail::status(p, ec: &ec)); |
| 207 | } |
| 208 | |
| 209 | inline bool is_symlink(path const& p) |
| 210 | { |
| 211 | return filesystem::is_symlink(f: detail::symlink_status(p)); |
| 212 | } |
| 213 | |
| 214 | inline bool is_symlink(path const& p, system::error_code& ec) noexcept |
| 215 | { |
| 216 | return filesystem::is_symlink(f: detail::symlink_status(p, ec: &ec)); |
| 217 | } |
| 218 | |
| 219 | inline bool is_block_file(path const& p) |
| 220 | { |
| 221 | return filesystem::is_block_file(f: detail::status(p)); |
| 222 | } |
| 223 | |
| 224 | inline bool is_block_file(path const& p, system::error_code& ec) noexcept |
| 225 | { |
| 226 | return filesystem::is_block_file(f: detail::status(p, ec: &ec)); |
| 227 | } |
| 228 | |
| 229 | inline bool is_character_file(path const& p) |
| 230 | { |
| 231 | return filesystem::is_character_file(f: detail::status(p)); |
| 232 | } |
| 233 | |
| 234 | inline bool is_character_file(path const& p, system::error_code& ec) noexcept |
| 235 | { |
| 236 | return filesystem::is_character_file(f: detail::status(p, ec: &ec)); |
| 237 | } |
| 238 | |
| 239 | inline bool is_fifo(path const& p) |
| 240 | { |
| 241 | return filesystem::is_fifo(f: detail::status(p)); |
| 242 | } |
| 243 | |
| 244 | inline bool is_fifo(path const& p, system::error_code& ec) noexcept |
| 245 | { |
| 246 | return filesystem::is_fifo(f: detail::status(p, ec: &ec)); |
| 247 | } |
| 248 | |
| 249 | inline bool is_socket(path const& p) |
| 250 | { |
| 251 | return filesystem::is_socket(f: detail::status(p)); |
| 252 | } |
| 253 | |
| 254 | inline bool is_socket(path const& p, system::error_code& ec) noexcept |
| 255 | { |
| 256 | return filesystem::is_socket(f: detail::status(p, ec: &ec)); |
| 257 | } |
| 258 | |
| 259 | inline bool is_reparse_file(path const& p) |
| 260 | { |
| 261 | return filesystem::is_reparse_file(f: detail::symlink_status(p)); |
| 262 | } |
| 263 | |
| 264 | inline bool is_reparse_file(path const& p, system::error_code& ec) noexcept |
| 265 | { |
| 266 | return filesystem::is_reparse_file(f: detail::symlink_status(p, ec: &ec)); |
| 267 | } |
| 268 | |
| 269 | inline bool is_other(path const& p) |
| 270 | { |
| 271 | return filesystem::is_other(f: detail::status(p)); |
| 272 | } |
| 273 | |
| 274 | inline bool is_other(path const& p, system::error_code& ec) noexcept |
| 275 | { |
| 276 | return filesystem::is_other(f: detail::status(p, ec: &ec)); |
| 277 | } |
| 278 | |
| 279 | inline bool is_empty(path const& p) |
| 280 | { |
| 281 | return detail::is_empty(p); |
| 282 | } |
| 283 | |
| 284 | inline bool is_empty(path const& p, system::error_code& ec) |
| 285 | { |
| 286 | return detail::is_empty(p, ec: &ec); |
| 287 | } |
| 288 | |
| 289 | //--------------------------------------------------------------------------------------// |
| 290 | // // |
| 291 | // operational functions // |
| 292 | // // |
| 293 | //--------------------------------------------------------------------------------------// |
| 294 | |
| 295 | inline path initial_path() |
| 296 | { |
| 297 | return detail::initial_path(); |
| 298 | } |
| 299 | |
| 300 | inline path initial_path(system::error_code& ec) |
| 301 | { |
| 302 | return detail::initial_path(ec: &ec); |
| 303 | } |
| 304 | |
| 305 | template< class Path > |
| 306 | path initial_path() |
| 307 | { |
| 308 | return initial_path(); |
| 309 | } |
| 310 | template< class Path > |
| 311 | path initial_path(system::error_code& ec) |
| 312 | { |
| 313 | return detail::initial_path(ec: &ec); |
| 314 | } |
| 315 | |
| 316 | inline path current_path() |
| 317 | { |
| 318 | return detail::current_path(); |
| 319 | } |
| 320 | |
| 321 | inline path current_path(system::error_code& ec) |
| 322 | { |
| 323 | return detail::current_path(ec: &ec); |
| 324 | } |
| 325 | |
| 326 | inline void current_path(path const& p) |
| 327 | { |
| 328 | detail::current_path(p); |
| 329 | } |
| 330 | |
| 331 | inline void current_path(path const& p, system::error_code& ec) noexcept |
| 332 | { |
| 333 | detail::current_path(p, ec: &ec); |
| 334 | } |
| 335 | |
| 336 | inline void copy(path const& from, path const& to) |
| 337 | { |
| 338 | detail::copy(from, to, options: copy_options::none); |
| 339 | } |
| 340 | |
| 341 | inline void copy(path const& from, path const& to, system::error_code& ec) noexcept |
| 342 | { |
| 343 | detail::copy(from, to, options: copy_options::none, ec: &ec); |
| 344 | } |
| 345 | |
| 346 | inline void copy(path const& from, path const& to, copy_options options) |
| 347 | { |
| 348 | detail::copy(from, to, options); |
| 349 | } |
| 350 | |
| 351 | inline void copy(path const& from, path const& to, copy_options options, system::error_code& ec) noexcept |
| 352 | { |
| 353 | detail::copy(from, to, options, ec: &ec); |
| 354 | } |
| 355 | |
| 356 | inline bool copy_file(path const& from, path const& to) |
| 357 | { |
| 358 | return detail::copy_file(from, to, options: copy_options::none); |
| 359 | } |
| 360 | |
| 361 | inline bool copy_file(path const& from, path const& to, system::error_code& ec) noexcept |
| 362 | { |
| 363 | return detail::copy_file(from, to, options: copy_options::none, ec: &ec); |
| 364 | } |
| 365 | |
| 366 | inline bool copy_file(path const& from, path const& to, copy_options options) |
| 367 | { |
| 368 | return detail::copy_file(from, to, options); |
| 369 | } |
| 370 | |
| 371 | inline bool copy_file(path const& from, path const& to, copy_options options, system::error_code& ec) noexcept |
| 372 | { |
| 373 | return detail::copy_file(from, to, options, ec: &ec); |
| 374 | } |
| 375 | |
| 376 | inline void copy_symlink(path const& existing_symlink, path const& new_symlink) |
| 377 | { |
| 378 | detail::copy_symlink(existing_symlink, new_symlink); |
| 379 | } |
| 380 | |
| 381 | inline void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code& ec) noexcept |
| 382 | { |
| 383 | detail::copy_symlink(existing_symlink, new_symlink, ec: &ec); |
| 384 | } |
| 385 | |
| 386 | inline bool create_directories(path const& p) |
| 387 | { |
| 388 | return detail::create_directories(p); |
| 389 | } |
| 390 | |
| 391 | inline bool create_directories(path const& p, system::error_code& ec) noexcept |
| 392 | { |
| 393 | return detail::create_directories(p, ec: &ec); |
| 394 | } |
| 395 | |
| 396 | inline bool create_directory(path const& p) |
| 397 | { |
| 398 | return detail::create_directory(p, existing: nullptr); |
| 399 | } |
| 400 | |
| 401 | inline bool create_directory(path const& p, system::error_code& ec) noexcept |
| 402 | { |
| 403 | return detail::create_directory(p, existing: nullptr, ec: &ec); |
| 404 | } |
| 405 | |
| 406 | inline bool create_directory(path const& p, path const& existing) |
| 407 | { |
| 408 | return detail::create_directory(p, existing: &existing); |
| 409 | } |
| 410 | |
| 411 | inline bool create_directory(path const& p, path const& existing, system::error_code& ec) noexcept |
| 412 | { |
| 413 | return detail::create_directory(p, existing: &existing, ec: &ec); |
| 414 | } |
| 415 | |
| 416 | inline void create_directory_symlink(path const& to, path const& from) |
| 417 | { |
| 418 | detail::create_directory_symlink(to, from); |
| 419 | } |
| 420 | |
| 421 | inline void create_directory_symlink(path const& to, path const& from, system::error_code& ec) noexcept |
| 422 | { |
| 423 | detail::create_directory_symlink(to, from, ec: &ec); |
| 424 | } |
| 425 | |
| 426 | inline void create_hard_link(path const& to, path const& new_hard_link) |
| 427 | { |
| 428 | detail::create_hard_link(to, from: new_hard_link); |
| 429 | } |
| 430 | |
| 431 | inline void create_hard_link(path const& to, path const& new_hard_link, system::error_code& ec) noexcept |
| 432 | { |
| 433 | detail::create_hard_link(to, from: new_hard_link, ec: &ec); |
| 434 | } |
| 435 | |
| 436 | inline void create_symlink(path const& to, path const& new_symlink) |
| 437 | { |
| 438 | detail::create_symlink(to, from: new_symlink); |
| 439 | } |
| 440 | |
| 441 | inline void create_symlink(path const& to, path const& new_symlink, system::error_code& ec) noexcept |
| 442 | { |
| 443 | detail::create_symlink(to, from: new_symlink, ec: &ec); |
| 444 | } |
| 445 | |
| 446 | inline boost::uintmax_t file_size(path const& p) |
| 447 | { |
| 448 | return detail::file_size(p); |
| 449 | } |
| 450 | |
| 451 | inline boost::uintmax_t file_size(path const& p, system::error_code& ec) noexcept |
| 452 | { |
| 453 | return detail::file_size(p, ec: &ec); |
| 454 | } |
| 455 | |
| 456 | inline boost::uintmax_t hard_link_count(path const& p) |
| 457 | { |
| 458 | return detail::hard_link_count(p); |
| 459 | } |
| 460 | |
| 461 | inline boost::uintmax_t hard_link_count(path const& p, system::error_code& ec) noexcept |
| 462 | { |
| 463 | return detail::hard_link_count(p, ec: &ec); |
| 464 | } |
| 465 | |
| 466 | inline std::time_t creation_time(path const& p) |
| 467 | { |
| 468 | return detail::creation_time(p); |
| 469 | } |
| 470 | |
| 471 | inline std::time_t creation_time(path const& p, system::error_code& ec) noexcept |
| 472 | { |
| 473 | return detail::creation_time(p, ec: &ec); |
| 474 | } |
| 475 | |
| 476 | inline std::time_t last_write_time(path const& p) |
| 477 | { |
| 478 | return detail::last_write_time(p); |
| 479 | } |
| 480 | |
| 481 | inline std::time_t last_write_time(path const& p, system::error_code& ec) noexcept |
| 482 | { |
| 483 | return detail::last_write_time(p, ec: &ec); |
| 484 | } |
| 485 | |
| 486 | inline void last_write_time(path const& p, const std::time_t new_time) |
| 487 | { |
| 488 | detail::last_write_time(p, new_time); |
| 489 | } |
| 490 | |
| 491 | inline void last_write_time(path const& p, const std::time_t new_time, system::error_code& ec) noexcept |
| 492 | { |
| 493 | detail::last_write_time(p, new_time, ec: &ec); |
| 494 | } |
| 495 | |
| 496 | inline void permissions(path const& p, perms prms) |
| 497 | { |
| 498 | detail::permissions(p, prms); |
| 499 | } |
| 500 | |
| 501 | inline void permissions(path const& p, perms prms, system::error_code& ec) noexcept |
| 502 | { |
| 503 | detail::permissions(p, prms, ec: &ec); |
| 504 | } |
| 505 | |
| 506 | inline path read_symlink(path const& p) |
| 507 | { |
| 508 | return detail::read_symlink(p); |
| 509 | } |
| 510 | |
| 511 | inline path read_symlink(path const& p, system::error_code& ec) |
| 512 | { |
| 513 | return detail::read_symlink(p, ec: &ec); |
| 514 | } |
| 515 | |
| 516 | inline bool remove(path const& p) |
| 517 | { |
| 518 | return detail::remove(p); |
| 519 | } |
| 520 | |
| 521 | inline bool remove(path const& p, system::error_code& ec) noexcept |
| 522 | { |
| 523 | return detail::remove(p, ec: &ec); |
| 524 | } |
| 525 | |
| 526 | inline boost::uintmax_t remove_all(path const& p) |
| 527 | { |
| 528 | return detail::remove_all(p); |
| 529 | } |
| 530 | |
| 531 | inline boost::uintmax_t remove_all(path const& p, system::error_code& ec) noexcept |
| 532 | { |
| 533 | return detail::remove_all(p, ec: &ec); |
| 534 | } |
| 535 | |
| 536 | inline void rename(path const& old_p, path const& new_p) |
| 537 | { |
| 538 | detail::rename(old_p, new_p); |
| 539 | } |
| 540 | |
| 541 | inline void rename(path const& old_p, path const& new_p, system::error_code& ec) noexcept |
| 542 | { |
| 543 | detail::rename(old_p, new_p, ec: &ec); |
| 544 | } |
| 545 | |
| 546 | // name suggested by Scott McMurray |
| 547 | inline void resize_file(path const& p, uintmax_t size) |
| 548 | { |
| 549 | detail::resize_file(p, size); |
| 550 | } |
| 551 | |
| 552 | inline void resize_file(path const& p, uintmax_t size, system::error_code& ec) noexcept |
| 553 | { |
| 554 | detail::resize_file(p, size, ec: &ec); |
| 555 | } |
| 556 | |
| 557 | inline path relative(path const& p, path const& base = current_path()) |
| 558 | { |
| 559 | return detail::relative(p, base); |
| 560 | } |
| 561 | |
| 562 | inline path relative(path const& p, system::error_code& ec) |
| 563 | { |
| 564 | path base = current_path(ec); |
| 565 | if (ec) |
| 566 | return path(); |
| 567 | return detail::relative(p, base, ec: &ec); |
| 568 | } |
| 569 | |
| 570 | inline path relative(path const& p, path const& base, system::error_code& ec) |
| 571 | { |
| 572 | return detail::relative(p, base, ec: &ec); |
| 573 | } |
| 574 | |
| 575 | inline space_info space(path const& p) |
| 576 | { |
| 577 | return detail::space(p); |
| 578 | } |
| 579 | |
| 580 | inline space_info space(path const& p, system::error_code& ec) noexcept |
| 581 | { |
| 582 | return detail::space(p, ec: &ec); |
| 583 | } |
| 584 | |
| 585 | inline path system_complete(path const& p) |
| 586 | { |
| 587 | return detail::system_complete(p); |
| 588 | } |
| 589 | |
| 590 | inline path system_complete(path const& p, system::error_code& ec) |
| 591 | { |
| 592 | return detail::system_complete(p, ec: &ec); |
| 593 | } |
| 594 | |
| 595 | inline path temp_directory_path() |
| 596 | { |
| 597 | return detail::temp_directory_path(); |
| 598 | } |
| 599 | |
| 600 | inline path temp_directory_path(system::error_code& ec) |
| 601 | { |
| 602 | return detail::temp_directory_path(ec: &ec); |
| 603 | } |
| 604 | |
| 605 | inline path unique_path(path const& p = |
| 606 | #if defined(BOOST_WINDOWS_API) |
| 607 | L"%%%%-%%%%-%%%%-%%%%" |
| 608 | #else |
| 609 | "%%%%-%%%%-%%%%-%%%%" |
| 610 | #endif |
| 611 | ) |
| 612 | { |
| 613 | return detail::unique_path(p); |
| 614 | } |
| 615 | |
| 616 | inline path unique_path(system::error_code& ec) |
| 617 | { |
| 618 | return detail::unique_path |
| 619 | ( |
| 620 | #if defined(BOOST_WINDOWS_API) |
| 621 | L"%%%%-%%%%-%%%%-%%%%" , |
| 622 | #else |
| 623 | p: "%%%%-%%%%-%%%%-%%%%" , |
| 624 | #endif |
| 625 | ec: &ec |
| 626 | ); |
| 627 | } |
| 628 | |
| 629 | inline path unique_path(path const& p, system::error_code& ec) |
| 630 | { |
| 631 | return detail::unique_path(p, ec: &ec); |
| 632 | } |
| 633 | |
| 634 | namespace BOOST_FILESYSTEM_VERSION_NAMESPACE { |
| 635 | |
| 636 | inline path absolute(path const& p, path const& base = current_path()) |
| 637 | { |
| 638 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::absolute)(p, base); |
| 639 | } |
| 640 | |
| 641 | inline path absolute(path const& p, system::error_code& ec) |
| 642 | { |
| 643 | path base = current_path(ec); |
| 644 | if (ec) |
| 645 | return path(); |
| 646 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::absolute)(p, base, ec: &ec); |
| 647 | } |
| 648 | |
| 649 | inline path absolute(path const& p, path const& base, system::error_code& ec) |
| 650 | { |
| 651 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::absolute)(p, base, ec: &ec); |
| 652 | } |
| 653 | |
| 654 | inline path canonical(path const& p, path const& base = current_path()) |
| 655 | { |
| 656 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::canonical)(p, base); |
| 657 | } |
| 658 | |
| 659 | inline path canonical(path const& p, system::error_code& ec) |
| 660 | { |
| 661 | path base = current_path(ec); |
| 662 | if (ec) |
| 663 | return path(); |
| 664 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::canonical)(p, base, ec: &ec); |
| 665 | } |
| 666 | |
| 667 | inline path canonical(path const& p, path const& base, system::error_code& ec) |
| 668 | { |
| 669 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::canonical)(p, base, ec: &ec); |
| 670 | } |
| 671 | |
| 672 | inline bool equivalent(path const& p1, path const& p2) |
| 673 | { |
| 674 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::equivalent)(p1, p2); |
| 675 | } |
| 676 | |
| 677 | inline bool equivalent(path const& p1, path const& p2, system::error_code& ec) noexcept |
| 678 | { |
| 679 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::equivalent)(p1, p2, ec: &ec); |
| 680 | } |
| 681 | |
| 682 | inline path weakly_canonical(path const& p, path const& base = current_path()) |
| 683 | { |
| 684 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::weakly_canonical)(p, base); |
| 685 | } |
| 686 | |
| 687 | inline path weakly_canonical(path const& p, system::error_code& ec) |
| 688 | { |
| 689 | path base = current_path(ec); |
| 690 | if (ec) |
| 691 | return path(); |
| 692 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::weakly_canonical)(p, base, ec: &ec); |
| 693 | } |
| 694 | |
| 695 | inline path weakly_canonical(path const& p, path const& base, system::error_code& ec) |
| 696 | { |
| 697 | return BOOST_FILESYSTEM_VERSIONED_SYM(detail::weakly_canonical)(p, base, ec: &ec); |
| 698 | } |
| 699 | |
| 700 | } // namespace BOOST_FILESYSTEM_VERSION_NAMESPACE |
| 701 | |
| 702 | using BOOST_FILESYSTEM_VERSION_NAMESPACE::absolute; |
| 703 | using BOOST_FILESYSTEM_VERSION_NAMESPACE::canonical; |
| 704 | using BOOST_FILESYSTEM_VERSION_NAMESPACE::equivalent; |
| 705 | using BOOST_FILESYSTEM_VERSION_NAMESPACE::weakly_canonical; |
| 706 | |
| 707 | // test helper -----------------------------------------------------------------------// |
| 708 | |
| 709 | // Not part of the documented interface since false positives are possible; |
| 710 | // there is no law that says that an OS that has large stat.st_size |
| 711 | // actually supports large file sizes. |
| 712 | |
| 713 | namespace detail { |
| 714 | |
| 715 | BOOST_FILESYSTEM_DECL bool possible_large_file_size_support(); |
| 716 | |
| 717 | } // namespace detail |
| 718 | |
| 719 | } // namespace filesystem |
| 720 | } // namespace boost |
| 721 | |
| 722 | #include <boost/filesystem/detail/footer.hpp> |
| 723 | |
| 724 | #endif // BOOST_FILESYSTEM_OPERATIONS_HPP |
| 725 | |