operations.hpp 21.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
//  boost/filesystem/operations.hpp  ---------------------------------------------------//

//  Copyright Beman Dawes 2002-2009
//  Copyright Jan Langer 2002
//  Copyright Dietmar Kuehl 2001
//  Copyright Vladimir Prus 2002
//  Copyright Andrey Semashev 2020-2021

//  Distributed under the Boost Software License, Version 1.0.
//  See http://www.boost.org/LICENSE_1_0.txt

//  Library home page: http://www.boost.org/libs/filesystem

//--------------------------------------------------------------------------------------//

#ifndef BOOST_FILESYSTEM_OPERATIONS_HPP
#define BOOST_FILESYSTEM_OPERATIONS_HPP

#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/file_status.hpp>

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
// These includes are left for backward compatibility and should be included directly by users, as needed
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/directory.hpp>
#endif

#include <boost/detail/bitmask.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/system/error_code.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
#include <ctime>
#include <string>

#include <boost/filesystem/detail/header.hpp> // must be the last #include

//--------------------------------------------------------------------------------------//

namespace boost {
namespace filesystem {

struct space_info
{
    // all values are byte counts
    boost::uintmax_t capacity;
    boost::uintmax_t free;      // <= capacity
    boost::uintmax_t available; // <= free
};

BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(copy_options, unsigned int)
{
    none = 0u, // Default. For copy_file: error if the target file exists. For copy: do not recurse, follow symlinks, copy file contents.

    // copy_file options:
    skip_existing = 1u,           // Don't overwrite the existing target file, don't report an error
    overwrite_existing = 1u << 1, // Overwrite existing file
    update_existing = 1u << 2,    // Overwrite existing file if its last write time is older than the replacement file
    synchronize_data = 1u << 3,   // Flush all buffered data written to the target file to permanent storage
    synchronize = 1u << 4,        // Flush all buffered data and attributes written to the target file to permanent storage

    // copy options:
    recursive = 1u << 8,          // Recurse into sub-directories
    copy_symlinks = 1u << 9,      // Copy symlinks as symlinks instead of copying the referenced file
    skip_symlinks = 1u << 10,     // Don't copy symlinks
    directories_only = 1u << 11,  // Only copy directory structure, do not copy non-directory files
    create_symlinks = 1u << 12,   // Create symlinks instead of copying files
    create_hard_links = 1u << 13, // Create hard links instead of copying files
    _detail_recursing = 1u << 14  // Internal use only, do not use
}
BOOST_SCOPED_ENUM_DECLARE_END(copy_options)

BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(copy_options))

#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_SCOPED_ENUM_DECLARE_BEGIN(copy_option)
{
    none = static_cast< unsigned int >(copy_options::none),
    fail_if_exists = none,
    overwrite_if_exists = static_cast< unsigned int >(copy_options::overwrite_existing)
}
BOOST_SCOPED_ENUM_DECLARE_END(copy_option)
#endif

//--------------------------------------------------------------------------------------//
//                             implementation details                                   //
//--------------------------------------------------------------------------------------//

namespace detail {

BOOST_FILESYSTEM_DECL
path absolute(path const& p, path const& base, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
file_status status(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
file_status symlink_status(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
bool is_empty(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path initial_path(system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path canonical(path const& p, path const& base, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void copy(path const& from, path const& to, unsigned int options, system::error_code* ec = NULL);
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_FILESYSTEM_DECL
void copy_directory(path const& from, path const& to, system::error_code* ec = NULL);
#endif
BOOST_FILESYSTEM_DECL
bool copy_file(path const& from, path const& to,                     // See ticket #2925
               unsigned int options, system::error_code* ec = NULL); // see copy_options for options
BOOST_FILESYSTEM_DECL
void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
bool create_directories(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
bool create_directory(path const& p, const path* existing, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void create_directory_symlink(path const& to, path const& from, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void create_hard_link(path const& to, path const& from, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void create_symlink(path const& to, path const& from, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path current_path(system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void current_path(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
bool equivalent(path const& p1, path const& p2, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
boost::uintmax_t file_size(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
boost::uintmax_t hard_link_count(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
std::time_t creation_time(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
std::time_t last_write_time(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void last_write_time(path const& p, const std::time_t new_time, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void permissions(path const& p, perms prms, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path read_symlink(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path relative(path const& p, path const& base, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
bool remove(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
boost::uintmax_t remove_all(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void rename(path const& old_p, path const& new_p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
void resize_file(path const& p, uintmax_t size, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
space_info space(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path system_complete(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path temp_directory_path(system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path unique_path(path const& p, system::error_code* ec = NULL);
BOOST_FILESYSTEM_DECL
path weakly_canonical(path const& p, path const& base, system::error_code* ec = NULL);

} // namespace detail

//--------------------------------------------------------------------------------------//
//                                                                                      //
//                             status query functions                                   //
//                                                                                      //
//--------------------------------------------------------------------------------------//

inline file_status status(path const& p)
{
    return detail::status(p);
}

inline file_status status(path const& p, system::error_code& ec)
{
    return detail::status(p, &ec);
}

inline file_status symlink_status(path const& p)
{
    return detail::symlink_status(p);
}

inline file_status symlink_status(path const& p, system::error_code& ec)
{
    return detail::symlink_status(p, &ec);
}

inline bool exists(path const& p)
{
    return exists(detail::status(p));
}

inline bool exists(path const& p, system::error_code& ec)
{
    return exists(detail::status(p, &ec));
}

inline bool is_directory(path const& p)
{
    return is_directory(detail::status(p));
}

inline bool is_directory(path const& p, system::error_code& ec)
{
    return is_directory(detail::status(p, &ec));
}

inline bool is_regular_file(path const& p)
{
    return is_regular_file(detail::status(p));
}

inline bool is_regular_file(path const& p, system::error_code& ec)
{
    return is_regular_file(detail::status(p, &ec));
}

inline bool is_other(path const& p)
{
    return is_other(detail::status(p));
}

inline bool is_other(path const& p, system::error_code& ec)
{
    return is_other(detail::status(p, &ec));
}

inline bool is_symlink(path const& p)
{
    return is_symlink(detail::symlink_status(p));
}

inline bool is_symlink(path const& p, system::error_code& ec)
{
    return is_symlink(detail::symlink_status(p, &ec));
}

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead")
inline bool is_regular(path const& p)
{
    return filesystem::is_regular_file(p);
}

BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead")
inline bool is_regular(path const& p, system::error_code& ec)
{
    return filesystem::is_regular_file(p, ec);
}
#endif

inline bool is_empty(path const& p)
{
    return detail::is_empty(p);
}

inline bool is_empty(path const& p, system::error_code& ec)
{
    return detail::is_empty(p, &ec);
}

//--------------------------------------------------------------------------------------//
//                                                                                      //
//                             operational functions                                    //
//                                                                                      //
//--------------------------------------------------------------------------------------//

inline path initial_path()
{
    return detail::initial_path();
}

inline path initial_path(system::error_code& ec)
{
    return detail::initial_path(&ec);
}

template< class Path >
path initial_path()
{
    return initial_path();
}
template< class Path >
path initial_path(system::error_code& ec)
{
    return detail::initial_path(&ec);
}

inline path current_path()
{
    return detail::current_path();
}

inline path current_path(system::error_code& ec)
{
    return detail::current_path(&ec);
}

inline void current_path(path const& p)
{
    detail::current_path(p);
}

inline void current_path(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::current_path(p, &ec);
}

inline path absolute(path const& p, path const& base = current_path())
{
    return detail::absolute(p, base);
}

inline path absolute(path const& p, system::error_code& ec)
{
    path base = current_path(ec);
    if (ec)
        return path();
    return detail::absolute(p, base, &ec);
}

inline path absolute(path const& p, path const& base, system::error_code& ec)
{
    return detail::absolute(p, base, &ec);
}

inline path canonical(path const& p, path const& base = current_path())
{
    return detail::canonical(p, base);
}

inline path canonical(path const& p, system::error_code& ec)
{
    path base = current_path(ec);
    if (ec)
        return path();
    return detail::canonical(p, base, &ec);
}

inline path canonical(path const& p, path const& base, system::error_code& ec)
{
    return detail::canonical(p, base, &ec);
}

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use absolute() instead")
inline path complete(path const& p)
{
    return absolute(p, initial_path());
}

BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use absolute() instead")
inline path complete(path const& p, path const& base)
{
    return absolute(p, base);
}
#endif

inline void copy(path const& from, path const& to)
{
    detail::copy(from, to, static_cast< unsigned int >(copy_options::none));
}

inline void copy(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::copy(from, to, static_cast< unsigned int >(copy_options::none), &ec);
}

inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
{
    detail::copy(from, to, static_cast< unsigned int >(options));
}

inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::copy(from, to, static_cast< unsigned int >(options), &ec);
}

#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use create_directory() instead")
inline void copy_directory(path const& from, path const& to)
{
    detail::copy_directory(from, to);
}

BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use create_directory() instead")
inline void copy_directory(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::copy_directory(from, to, &ec);
}
#endif

inline bool copy_file(path const& from, path const& to)
{
    return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none));
}

inline bool copy_file(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none), &ec);
}

inline bool copy_file(path const& from, path const& to, // See ticket #2925
                      BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
{
    return detail::copy_file(from, to, static_cast< unsigned int >(options));
}

inline bool copy_file(path const& from, path const& to, // See ticket #2925
                      BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
}

#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use copy_options instead of copy_option")
inline bool copy_file(path const& from, path const& to, // See ticket #2925
                      BOOST_SCOPED_ENUM_NATIVE(copy_option) options)
{
    return detail::copy_file(from, to, static_cast< unsigned int >(options));
}

BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use copy_options instead of copy_option")
inline bool copy_file(path const& from, path const& to, // See ticket #2925
                      BOOST_SCOPED_ENUM_NATIVE(copy_option) options, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
}
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)

inline void copy_symlink(path const& existing_symlink, path const& new_symlink)
{
    detail::copy_symlink(existing_symlink, new_symlink);
}

inline void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::copy_symlink(existing_symlink, new_symlink, &ec);
}

inline bool create_directories(path const& p)
{
    return detail::create_directories(p);
}

inline bool create_directories(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::create_directories(p, &ec);
}

inline bool create_directory(path const& p)
{
    return detail::create_directory(p, NULL);
}

inline bool create_directory(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::create_directory(p, NULL, &ec);
}

inline bool create_directory(path const& p, path const& existing)
{
    return detail::create_directory(p, &existing);
}

inline bool create_directory(path const& p, path const& existing, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::create_directory(p, &existing, &ec);
}

inline void create_directory_symlink(path const& to, path const& from)
{
    detail::create_directory_symlink(to, from);
}

inline void create_directory_symlink(path const& to, path const& from, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::create_directory_symlink(to, from, &ec);
}

inline void create_hard_link(path const& to, path const& new_hard_link)
{
    detail::create_hard_link(to, new_hard_link);
}

inline void create_hard_link(path const& to, path const& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::create_hard_link(to, new_hard_link, &ec);
}

inline void create_symlink(path const& to, path const& new_symlink)
{
    detail::create_symlink(to, new_symlink);
}

inline void create_symlink(path const& to, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::create_symlink(to, new_symlink, &ec);
}

inline bool equivalent(path const& p1, path const& p2)
{
    return detail::equivalent(p1, p2);
}

inline bool equivalent(path const& p1, path const& p2, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::equivalent(p1, p2, &ec);
}

inline boost::uintmax_t file_size(path const& p)
{
    return detail::file_size(p);
}

inline boost::uintmax_t file_size(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::file_size(p, &ec);
}

inline boost::uintmax_t hard_link_count(path const& p)
{
    return detail::hard_link_count(p);
}

inline boost::uintmax_t hard_link_count(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::hard_link_count(p, &ec);
}

inline std::time_t creation_time(path const& p)
{
    return detail::creation_time(p);
}

inline std::time_t creation_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::creation_time(p, &ec);
}

inline std::time_t last_write_time(path const& p)
{
    return detail::last_write_time(p);
}

inline std::time_t last_write_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::last_write_time(p, &ec);
}

inline void last_write_time(path const& p, const std::time_t new_time)
{
    detail::last_write_time(p, new_time);
}

inline void last_write_time(path const& p, const std::time_t new_time, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::last_write_time(p, new_time, &ec);
}

inline void permissions(path const& p, perms prms)
{
    detail::permissions(p, prms);
}

inline void permissions(path const& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::permissions(p, prms, &ec);
}

inline path read_symlink(path const& p)
{
    return detail::read_symlink(p);
}

inline path read_symlink(path const& p, system::error_code& ec)
{
    return detail::read_symlink(p, &ec);
}

inline bool remove(path const& p)
{
    return detail::remove(p);
}

inline bool remove(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::remove(p, &ec);
}

inline boost::uintmax_t remove_all(path const& p)
{
    return detail::remove_all(p);
}

inline boost::uintmax_t remove_all(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::remove_all(p, &ec);
}

inline void rename(path const& old_p, path const& new_p)
{
    detail::rename(old_p, new_p);
}

inline void rename(path const& old_p, path const& new_p, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::rename(old_p, new_p, &ec);
}

// name suggested by Scott McMurray
inline void resize_file(path const& p, uintmax_t size)
{
    detail::resize_file(p, size);
}

inline void resize_file(path const& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
{
    detail::resize_file(p, size, &ec);
}

inline path relative(path const& p, path const& base = current_path())
{
    return detail::relative(p, base);
}

inline path relative(path const& p, system::error_code& ec)
{
    path base = current_path(ec);
    if (ec)
        return path();
    return detail::relative(p, base, &ec);
}

inline path relative(path const& p, path const& base, system::error_code& ec)
{
    return detail::relative(p, base, &ec);
}

inline space_info space(path const& p)
{
    return detail::space(p);
}

inline space_info space(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
    return detail::space(p, &ec);
}

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_symlink(symlink_status(path)) instead")
inline bool symbolic_link_exists(path const& p)
{
    return is_symlink(filesystem::symlink_status(p));
}
#endif

inline path system_complete(path const& p)
{
    return detail::system_complete(p);
}

inline path system_complete(path const& p, system::error_code& ec)
{
    return detail::system_complete(p, &ec);
}

inline path temp_directory_path()
{
    return detail::temp_directory_path();
}

inline path temp_directory_path(system::error_code& ec)
{
    return detail::temp_directory_path(&ec);
}

inline path unique_path(path const& p = "%%%%-%%%%-%%%%-%%%%")
{
    return detail::unique_path(p);
}

inline path unique_path(path const& p, system::error_code& ec)
{
    return detail::unique_path(p, &ec);
}

inline path weakly_canonical(path const& p, path const& base = current_path())
{
    return detail::weakly_canonical(p, base);
}

inline path weakly_canonical(path const& p, system::error_code& ec)
{
    path base = current_path(ec);
    if (ec)
        return path();
    return detail::weakly_canonical(p, base, &ec);
}

inline path weakly_canonical(path const& p, path const& base, system::error_code& ec)
{
    return detail::weakly_canonical(p, base, &ec);
}

//  test helper  -----------------------------------------------------------------------//

//  Not part of the documented interface since false positives are possible;
//  there is no law that says that an OS that has large stat.st_size
//  actually supports large file sizes.

namespace detail {

BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();

} // namespace detail

} // namespace filesystem
} // namespace boost

#include <boost/filesystem/detail/footer.hpp>

#endif // BOOST_FILESYSTEM_OPERATIONS_HPP