operations.hpp 21 KB

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