operations.hpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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) BOOST_NOEXCEPT
  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) BOOST_NOEXCEPT
  164. {
  165. return detail::symlink_status(p, &ec);
  166. }
  167. inline bool exists(path const& p)
  168. {
  169. return filesystem::exists(detail::status(p));
  170. }
  171. inline bool exists(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  172. {
  173. return filesystem::exists(detail::status(p, &ec));
  174. }
  175. inline bool is_regular_file(path const& p)
  176. {
  177. return filesystem::is_regular_file(detail::status(p));
  178. }
  179. inline bool is_regular_file(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  180. {
  181. return filesystem::is_regular_file(detail::status(p, &ec));
  182. }
  183. inline bool is_directory(path const& p)
  184. {
  185. return filesystem::is_directory(detail::status(p));
  186. }
  187. inline bool is_directory(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  188. {
  189. return filesystem::is_directory(detail::status(p, &ec));
  190. }
  191. inline bool is_symlink(path const& p)
  192. {
  193. return filesystem::is_symlink(detail::symlink_status(p));
  194. }
  195. inline bool is_symlink(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  196. {
  197. return filesystem::is_symlink(detail::symlink_status(p, &ec));
  198. }
  199. inline bool is_block_file(path const& p)
  200. {
  201. return filesystem::is_block_file(detail::status(p));
  202. }
  203. inline bool is_block_file(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  204. {
  205. return filesystem::is_block_file(detail::status(p, &ec));
  206. }
  207. inline bool is_character_file(path const& p)
  208. {
  209. return filesystem::is_character_file(detail::status(p));
  210. }
  211. inline bool is_character_file(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  212. {
  213. return filesystem::is_character_file(detail::status(p, &ec));
  214. }
  215. inline bool is_fifo(path const& p)
  216. {
  217. return filesystem::is_fifo(detail::status(p));
  218. }
  219. inline bool is_fifo(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  220. {
  221. return filesystem::is_fifo(detail::status(p, &ec));
  222. }
  223. inline bool is_socket(path const& p)
  224. {
  225. return filesystem::is_socket(detail::status(p));
  226. }
  227. inline bool is_socket(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  228. {
  229. return filesystem::is_socket(detail::status(p, &ec));
  230. }
  231. inline bool is_reparse_file(path const& p)
  232. {
  233. return filesystem::is_reparse_file(detail::symlink_status(p));
  234. }
  235. inline bool is_reparse_file(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  236. {
  237. return filesystem::is_reparse_file(detail::symlink_status(p, &ec));
  238. }
  239. inline bool is_other(path const& p)
  240. {
  241. return filesystem::is_other(detail::status(p));
  242. }
  243. inline bool is_other(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  244. {
  245. return filesystem::is_other(detail::status(p, &ec));
  246. }
  247. #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
  248. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead")
  249. inline bool is_regular(path const& p)
  250. {
  251. return filesystem::is_regular_file(p);
  252. }
  253. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_regular_file() instead")
  254. inline bool is_regular(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  255. {
  256. return filesystem::is_regular_file(p, ec);
  257. }
  258. #endif
  259. inline bool is_empty(path const& p)
  260. {
  261. return detail::is_empty(p);
  262. }
  263. inline bool is_empty(path const& p, system::error_code& ec)
  264. {
  265. return detail::is_empty(p, &ec);
  266. }
  267. //--------------------------------------------------------------------------------------//
  268. // //
  269. // operational functions //
  270. // //
  271. //--------------------------------------------------------------------------------------//
  272. inline path initial_path()
  273. {
  274. return detail::initial_path();
  275. }
  276. inline path initial_path(system::error_code& ec)
  277. {
  278. return detail::initial_path(&ec);
  279. }
  280. template< class Path >
  281. path initial_path()
  282. {
  283. return initial_path();
  284. }
  285. template< class Path >
  286. path initial_path(system::error_code& ec)
  287. {
  288. return detail::initial_path(&ec);
  289. }
  290. inline path current_path()
  291. {
  292. return detail::current_path();
  293. }
  294. inline path current_path(system::error_code& ec)
  295. {
  296. return detail::current_path(&ec);
  297. }
  298. inline void current_path(path const& p)
  299. {
  300. detail::current_path(p);
  301. }
  302. inline void current_path(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  303. {
  304. detail::current_path(p, &ec);
  305. }
  306. inline path absolute(path const& p, path const& base = current_path())
  307. {
  308. return detail::absolute(p, base);
  309. }
  310. inline path absolute(path const& p, system::error_code& ec)
  311. {
  312. path base = current_path(ec);
  313. if (ec)
  314. return path();
  315. return detail::absolute(p, base, &ec);
  316. }
  317. inline path absolute(path const& p, path const& base, system::error_code& ec)
  318. {
  319. return detail::absolute(p, base, &ec);
  320. }
  321. inline path canonical(path const& p, path const& base = current_path())
  322. {
  323. return detail::canonical(p, base);
  324. }
  325. inline path canonical(path const& p, system::error_code& ec)
  326. {
  327. path base = current_path(ec);
  328. if (ec)
  329. return path();
  330. return detail::canonical(p, base, &ec);
  331. }
  332. inline path canonical(path const& p, path const& base, system::error_code& ec)
  333. {
  334. return detail::canonical(p, base, &ec);
  335. }
  336. #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
  337. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use absolute() instead")
  338. inline path complete(path const& p)
  339. {
  340. return absolute(p, initial_path());
  341. }
  342. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use absolute() instead")
  343. inline path complete(path const& p, path const& base)
  344. {
  345. return absolute(p, base);
  346. }
  347. #endif
  348. inline void copy(path const& from, path const& to)
  349. {
  350. detail::copy(from, to, static_cast< unsigned int >(copy_options::none));
  351. }
  352. inline void copy(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
  353. {
  354. detail::copy(from, to, static_cast< unsigned int >(copy_options::none), &ec);
  355. }
  356. inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
  357. {
  358. detail::copy(from, to, static_cast< unsigned int >(options));
  359. }
  360. inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
  361. {
  362. detail::copy(from, to, static_cast< unsigned int >(options), &ec);
  363. }
  364. #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
  365. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use create_directory() instead")
  366. inline void copy_directory(path const& from, path const& to)
  367. {
  368. detail::copy_directory(from, to);
  369. }
  370. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use create_directory() instead")
  371. inline void copy_directory(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
  372. {
  373. detail::copy_directory(from, to, &ec);
  374. }
  375. #endif
  376. inline bool copy_file(path const& from, path const& to)
  377. {
  378. return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none));
  379. }
  380. inline bool copy_file(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
  381. {
  382. return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none), &ec);
  383. }
  384. inline bool copy_file(path const& from, path const& to, // See ticket #2925
  385. BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
  386. {
  387. return detail::copy_file(from, to, static_cast< unsigned int >(options));
  388. }
  389. inline bool copy_file(path const& from, path const& to, // See ticket #2925
  390. BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
  391. {
  392. return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
  393. }
  394. #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
  395. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use copy_options instead of copy_option")
  396. inline bool copy_file(path const& from, path const& to, // See ticket #2925
  397. BOOST_SCOPED_ENUM_NATIVE(copy_option) options)
  398. {
  399. return detail::copy_file(from, to, static_cast< unsigned int >(options));
  400. }
  401. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use copy_options instead of copy_option")
  402. inline bool copy_file(path const& from, path const& to, // See ticket #2925
  403. BOOST_SCOPED_ENUM_NATIVE(copy_option) options, system::error_code& ec) BOOST_NOEXCEPT
  404. {
  405. return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
  406. }
  407. #endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
  408. inline void copy_symlink(path const& existing_symlink, path const& new_symlink)
  409. {
  410. detail::copy_symlink(existing_symlink, new_symlink);
  411. }
  412. inline void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
  413. {
  414. detail::copy_symlink(existing_symlink, new_symlink, &ec);
  415. }
  416. inline bool create_directories(path const& p)
  417. {
  418. return detail::create_directories(p);
  419. }
  420. inline bool create_directories(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  421. {
  422. return detail::create_directories(p, &ec);
  423. }
  424. inline bool create_directory(path const& p)
  425. {
  426. return detail::create_directory(p, NULL);
  427. }
  428. inline bool create_directory(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  429. {
  430. return detail::create_directory(p, NULL, &ec);
  431. }
  432. inline bool create_directory(path const& p, path const& existing)
  433. {
  434. return detail::create_directory(p, &existing);
  435. }
  436. inline bool create_directory(path const& p, path const& existing, system::error_code& ec) BOOST_NOEXCEPT
  437. {
  438. return detail::create_directory(p, &existing, &ec);
  439. }
  440. inline void create_directory_symlink(path const& to, path const& from)
  441. {
  442. detail::create_directory_symlink(to, from);
  443. }
  444. inline void create_directory_symlink(path const& to, path const& from, system::error_code& ec) BOOST_NOEXCEPT
  445. {
  446. detail::create_directory_symlink(to, from, &ec);
  447. }
  448. inline void create_hard_link(path const& to, path const& new_hard_link)
  449. {
  450. detail::create_hard_link(to, new_hard_link);
  451. }
  452. inline void create_hard_link(path const& to, path const& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
  453. {
  454. detail::create_hard_link(to, new_hard_link, &ec);
  455. }
  456. inline void create_symlink(path const& to, path const& new_symlink)
  457. {
  458. detail::create_symlink(to, new_symlink);
  459. }
  460. inline void create_symlink(path const& to, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
  461. {
  462. detail::create_symlink(to, new_symlink, &ec);
  463. }
  464. inline bool equivalent(path const& p1, path const& p2)
  465. {
  466. return detail::equivalent(p1, p2);
  467. }
  468. inline bool equivalent(path const& p1, path const& p2, system::error_code& ec) BOOST_NOEXCEPT
  469. {
  470. return detail::equivalent(p1, p2, &ec);
  471. }
  472. inline boost::uintmax_t file_size(path const& p)
  473. {
  474. return detail::file_size(p);
  475. }
  476. inline boost::uintmax_t file_size(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  477. {
  478. return detail::file_size(p, &ec);
  479. }
  480. inline boost::uintmax_t hard_link_count(path const& p)
  481. {
  482. return detail::hard_link_count(p);
  483. }
  484. inline boost::uintmax_t hard_link_count(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  485. {
  486. return detail::hard_link_count(p, &ec);
  487. }
  488. inline std::time_t creation_time(path const& p)
  489. {
  490. return detail::creation_time(p);
  491. }
  492. inline std::time_t creation_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  493. {
  494. return detail::creation_time(p, &ec);
  495. }
  496. inline std::time_t last_write_time(path const& p)
  497. {
  498. return detail::last_write_time(p);
  499. }
  500. inline std::time_t last_write_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  501. {
  502. return detail::last_write_time(p, &ec);
  503. }
  504. inline void last_write_time(path const& p, const std::time_t new_time)
  505. {
  506. detail::last_write_time(p, new_time);
  507. }
  508. inline void last_write_time(path const& p, const std::time_t new_time, system::error_code& ec) BOOST_NOEXCEPT
  509. {
  510. detail::last_write_time(p, new_time, &ec);
  511. }
  512. inline void permissions(path const& p, perms prms)
  513. {
  514. detail::permissions(p, prms);
  515. }
  516. inline void permissions(path const& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
  517. {
  518. detail::permissions(p, prms, &ec);
  519. }
  520. inline path read_symlink(path const& p)
  521. {
  522. return detail::read_symlink(p);
  523. }
  524. inline path read_symlink(path const& p, system::error_code& ec)
  525. {
  526. return detail::read_symlink(p, &ec);
  527. }
  528. inline bool remove(path const& p)
  529. {
  530. return detail::remove(p);
  531. }
  532. inline bool remove(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  533. {
  534. return detail::remove(p, &ec);
  535. }
  536. inline boost::uintmax_t remove_all(path const& p)
  537. {
  538. return detail::remove_all(p);
  539. }
  540. inline boost::uintmax_t remove_all(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  541. {
  542. return detail::remove_all(p, &ec);
  543. }
  544. inline void rename(path const& old_p, path const& new_p)
  545. {
  546. detail::rename(old_p, new_p);
  547. }
  548. inline void rename(path const& old_p, path const& new_p, system::error_code& ec) BOOST_NOEXCEPT
  549. {
  550. detail::rename(old_p, new_p, &ec);
  551. }
  552. // name suggested by Scott McMurray
  553. inline void resize_file(path const& p, uintmax_t size)
  554. {
  555. detail::resize_file(p, size);
  556. }
  557. inline void resize_file(path const& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
  558. {
  559. detail::resize_file(p, size, &ec);
  560. }
  561. inline path relative(path const& p, path const& base = current_path())
  562. {
  563. return detail::relative(p, base);
  564. }
  565. inline path relative(path const& p, system::error_code& ec)
  566. {
  567. path base = current_path(ec);
  568. if (ec)
  569. return path();
  570. return detail::relative(p, base, &ec);
  571. }
  572. inline path relative(path const& p, path const& base, system::error_code& ec)
  573. {
  574. return detail::relative(p, base, &ec);
  575. }
  576. inline space_info space(path const& p)
  577. {
  578. return detail::space(p);
  579. }
  580. inline space_info space(path const& p, system::error_code& ec) BOOST_NOEXCEPT
  581. {
  582. return detail::space(p, &ec);
  583. }
  584. #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
  585. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use is_symlink(symlink_status(path)) instead")
  586. inline bool symbolic_link_exists(path const& p)
  587. {
  588. return is_symlink(filesystem::symlink_status(p));
  589. }
  590. #endif
  591. inline path system_complete(path const& p)
  592. {
  593. return detail::system_complete(p);
  594. }
  595. inline path system_complete(path const& p, system::error_code& ec)
  596. {
  597. return detail::system_complete(p, &ec);
  598. }
  599. inline path temp_directory_path()
  600. {
  601. return detail::temp_directory_path();
  602. }
  603. inline path temp_directory_path(system::error_code& ec)
  604. {
  605. return detail::temp_directory_path(&ec);
  606. }
  607. inline path unique_path(path const& p = "%%%%-%%%%-%%%%-%%%%")
  608. {
  609. return detail::unique_path(p);
  610. }
  611. inline path unique_path(path const& p, system::error_code& ec)
  612. {
  613. return detail::unique_path(p, &ec);
  614. }
  615. inline path weakly_canonical(path const& p, path const& base = current_path())
  616. {
  617. return detail::weakly_canonical(p, base);
  618. }
  619. inline path weakly_canonical(path const& p, system::error_code& ec)
  620. {
  621. path base = current_path(ec);
  622. if (ec)
  623. return path();
  624. return detail::weakly_canonical(p, base, &ec);
  625. }
  626. inline path weakly_canonical(path const& p, path const& base, system::error_code& ec)
  627. {
  628. return detail::weakly_canonical(p, base, &ec);
  629. }
  630. // test helper -----------------------------------------------------------------------//
  631. // Not part of the documented interface since false positives are possible;
  632. // there is no law that says that an OS that has large stat.st_size
  633. // actually supports large file sizes.
  634. namespace detail {
  635. BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
  636. } // namespace detail
  637. } // namespace filesystem
  638. } // namespace boost
  639. #include <boost/filesystem/detail/footer.hpp>
  640. #endif // BOOST_FILESYSTEM_OPERATIONS_HPP