fs_ops.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. // Filesystem operational functions -*- C++ -*-
  2. // Copyright (C) 2014-2018 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your __option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file include/bits/fs_fwd.h
  21. * This is an internal header file, included by other library headers.
  22. * Do not attempt to use it directly. @headername{filesystem}
  23. */
  24. #ifndef _GLIBCXX_FS_OPS_H
  25. #define _GLIBCXX_FS_OPS_H 1
  26. #if __cplusplus >= 201703L
  27. #include <cstdint>
  28. namespace std _GLIBCXX_VISIBILITY(default)
  29. {
  30. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  31. namespace filesystem
  32. {
  33. /**
  34. * @ingroup filesystem
  35. * @{
  36. */
  37. path absolute(const path& __p);
  38. path absolute(const path& __p, error_code& __ec);
  39. path canonical(const path& __p);
  40. path canonical(const path& __p, error_code& __ec);
  41. inline void
  42. copy(const path& __from, const path& __to)
  43. { copy(__from, __to, copy_options::none); }
  44. inline void
  45. copy(const path& __from, const path& __to, error_code& __ec)
  46. { copy(__from, __to, copy_options::none, __ec); }
  47. void copy(const path& __from, const path& __to, copy_options __options);
  48. void copy(const path& __from, const path& __to, copy_options __options,
  49. error_code& __ec);
  50. inline bool
  51. copy_file(const path& __from, const path& __to)
  52. { return copy_file(__from, __to, copy_options::none); }
  53. inline bool
  54. copy_file(const path& __from, const path& __to, error_code& __ec)
  55. { return copy_file(__from, __to, copy_options::none, __ec); }
  56. bool copy_file(const path& __from, const path& __to, copy_options __option);
  57. bool copy_file(const path& __from, const path& __to, copy_options __option,
  58. error_code& __ec);
  59. void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
  60. void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
  61. error_code& __ec) noexcept;
  62. bool create_directories(const path& __p);
  63. bool create_directories(const path& __p, error_code& __ec);
  64. bool create_directory(const path& __p);
  65. bool create_directory(const path& __p, error_code& __ec) noexcept;
  66. bool create_directory(const path& __p, const path& attributes);
  67. bool create_directory(const path& __p, const path& attributes,
  68. error_code& __ec) noexcept;
  69. void create_directory_symlink(const path& __to, const path& __new_symlink);
  70. void create_directory_symlink(const path& __to, const path& __new_symlink,
  71. error_code& __ec) noexcept;
  72. void create_hard_link(const path& __to, const path& __new_hard_link);
  73. void create_hard_link(const path& __to, const path& __new_hard_link,
  74. error_code& __ec) noexcept;
  75. void create_symlink(const path& __to, const path& __new_symlink);
  76. void create_symlink(const path& __to, const path& __new_symlink,
  77. error_code& __ec) noexcept;
  78. path current_path();
  79. path current_path(error_code& __ec);
  80. void current_path(const path& __p);
  81. void current_path(const path& __p, error_code& __ec) noexcept;
  82. bool
  83. equivalent(const path& __p1, const path& __p2);
  84. bool
  85. equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
  86. inline bool
  87. exists(file_status __s) noexcept
  88. { return status_known(__s) && __s.type() != file_type::not_found; }
  89. inline bool
  90. exists(const path& __p)
  91. { return exists(status(__p)); }
  92. inline bool
  93. exists(const path& __p, error_code& __ec) noexcept
  94. {
  95. auto __s = status(__p, __ec);
  96. if (status_known(__s))
  97. {
  98. __ec.clear();
  99. return __s.type() != file_type::not_found;
  100. }
  101. return false;
  102. }
  103. uintmax_t file_size(const path& __p);
  104. uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
  105. uintmax_t hard_link_count(const path& __p);
  106. uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
  107. inline bool
  108. is_block_file(file_status __s) noexcept
  109. { return __s.type() == file_type::block; }
  110. inline bool
  111. is_block_file(const path& __p)
  112. { return is_block_file(status(__p)); }
  113. inline bool
  114. is_block_file(const path& __p, error_code& __ec) noexcept
  115. { return is_block_file(status(__p, __ec)); }
  116. inline bool
  117. is_character_file(file_status __s) noexcept
  118. { return __s.type() == file_type::character; }
  119. inline bool
  120. is_character_file(const path& __p)
  121. { return is_character_file(status(__p)); }
  122. inline bool
  123. is_character_file(const path& __p, error_code& __ec) noexcept
  124. { return is_character_file(status(__p, __ec)); }
  125. inline bool
  126. is_directory(file_status __s) noexcept
  127. { return __s.type() == file_type::directory; }
  128. inline bool
  129. is_directory(const path& __p)
  130. { return is_directory(status(__p)); }
  131. inline bool
  132. is_directory(const path& __p, error_code& __ec) noexcept
  133. { return is_directory(status(__p, __ec)); }
  134. bool is_empty(const path& __p);
  135. bool is_empty(const path& __p, error_code& __ec);
  136. inline bool
  137. is_fifo(file_status __s) noexcept
  138. { return __s.type() == file_type::fifo; }
  139. inline bool
  140. is_fifo(const path& __p)
  141. { return is_fifo(status(__p)); }
  142. inline bool
  143. is_fifo(const path& __p, error_code& __ec) noexcept
  144. { return is_fifo(status(__p, __ec)); }
  145. inline bool
  146. is_other(file_status __s) noexcept
  147. {
  148. return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
  149. && !is_symlink(__s);
  150. }
  151. inline bool
  152. is_other(const path& __p)
  153. { return is_other(status(__p)); }
  154. inline bool
  155. is_other(const path& __p, error_code& __ec) noexcept
  156. { return is_other(status(__p, __ec)); }
  157. inline bool
  158. is_regular_file(file_status __s) noexcept
  159. { return __s.type() == file_type::regular; }
  160. inline bool
  161. is_regular_file(const path& __p)
  162. { return is_regular_file(status(__p)); }
  163. inline bool
  164. is_regular_file(const path& __p, error_code& __ec) noexcept
  165. { return is_regular_file(status(__p, __ec)); }
  166. inline bool
  167. is_socket(file_status __s) noexcept
  168. { return __s.type() == file_type::socket; }
  169. inline bool
  170. is_socket(const path& __p)
  171. { return is_socket(status(__p)); }
  172. inline bool
  173. is_socket(const path& __p, error_code& __ec) noexcept
  174. { return is_socket(status(__p, __ec)); }
  175. inline bool
  176. is_symlink(file_status __s) noexcept
  177. { return __s.type() == file_type::symlink; }
  178. inline bool
  179. is_symlink(const path& __p)
  180. { return is_symlink(symlink_status(__p)); }
  181. inline bool
  182. is_symlink(const path& __p, error_code& __ec) noexcept
  183. { return is_symlink(symlink_status(__p, __ec)); }
  184. file_time_type last_write_time(const path& __p);
  185. file_time_type last_write_time(const path& __p, error_code& __ec) noexcept;
  186. void last_write_time(const path& __p, file_time_type __new_time);
  187. void last_write_time(const path& __p, file_time_type __new_time,
  188. error_code& __ec) noexcept;
  189. void
  190. permissions(const path& __p, perms __prms,
  191. perm_options __opts = perm_options::replace);
  192. inline void
  193. permissions(const path& __p, perms __prms, error_code& __ec) noexcept
  194. { permissions(__p, __prms, perm_options::replace, __ec); }
  195. void
  196. permissions(const path& __p, perms __prms, perm_options __opts,
  197. error_code& __ec) noexcept;
  198. inline path proximate(const path& __p, error_code& __ec)
  199. { return proximate(__p, current_path(), __ec); }
  200. path proximate(const path& __p, const path& __base = current_path());
  201. path proximate(const path& __p, const path& __base, error_code& __ec);
  202. path read_symlink(const path& __p);
  203. path read_symlink(const path& __p, error_code& __ec);
  204. inline path relative(const path& __p, error_code& __ec)
  205. { return relative(__p, current_path(), __ec); }
  206. path relative(const path& __p, const path& __base = current_path());
  207. path relative(const path& __p, const path& __base, error_code& __ec);
  208. bool remove(const path& __p);
  209. bool remove(const path& __p, error_code& __ec) noexcept;
  210. uintmax_t remove_all(const path& __p);
  211. uintmax_t remove_all(const path& __p, error_code& __ec);
  212. void rename(const path& __from, const path& __to);
  213. void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
  214. void resize_file(const path& __p, uintmax_t __size);
  215. void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
  216. space_info space(const path& __p);
  217. space_info space(const path& __p, error_code& __ec) noexcept;
  218. file_status status(const path& __p);
  219. file_status status(const path& __p, error_code& __ec) noexcept;
  220. inline bool status_known(file_status __s) noexcept
  221. { return __s.type() != file_type::none; }
  222. file_status symlink_status(const path& __p);
  223. file_status symlink_status(const path& __p, error_code& __ec) noexcept;
  224. path temp_directory_path();
  225. path temp_directory_path(error_code& __ec);
  226. path weakly_canonical(const path& __p);
  227. path weakly_canonical(const path& __p, error_code& __ec);
  228. // @} group filesystem
  229. } // namespace filesystem
  230. _GLIBCXX_END_NAMESPACE_VERSION
  231. } // namespace std
  232. #endif // C++17
  233. #endif // _GLIBCXX_FS_OPS_H