operations.hpp 21 KB

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