File indexing completed on 2026-05-03 08:13:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___FILESYSTEM_OPERATIONS_H
0011 #define _LIBCPP___CXX03___FILESYSTEM_OPERATIONS_H
0012
0013 #include <__cxx03/__chrono/time_point.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__filesystem/copy_options.h>
0016 #include <__cxx03/__filesystem/file_status.h>
0017 #include <__cxx03/__filesystem/file_time_type.h>
0018 #include <__cxx03/__filesystem/file_type.h>
0019 #include <__cxx03/__filesystem/path.h>
0020 #include <__cxx03/__filesystem/perm_options.h>
0021 #include <__cxx03/__filesystem/perms.h>
0022 #include <__cxx03/__filesystem/space_info.h>
0023 #include <__cxx03/__system_error/error_code.h>
0024 #include <__cxx03/cstdint>
0025
0026 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0027 # pragma GCC system_header
0028 #endif
0029
0030 #if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
0031
0032 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
0033
0034 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
0035
0036 _LIBCPP_EXPORTED_FROM_ABI path __absolute(const path&, error_code* __ec = nullptr);
0037 _LIBCPP_EXPORTED_FROM_ABI path __canonical(const path&, error_code* __ec = nullptr);
0038 _LIBCPP_EXPORTED_FROM_ABI bool
0039 __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
0040 _LIBCPP_EXPORTED_FROM_ABI void
0041 __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr);
0042 _LIBCPP_EXPORTED_FROM_ABI void
0043 __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
0044 _LIBCPP_EXPORTED_FROM_ABI bool __create_directories(const path&, error_code* = nullptr);
0045 _LIBCPP_EXPORTED_FROM_ABI void
0046 __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
0047 _LIBCPP_EXPORTED_FROM_ABI bool __create_directory(const path&, error_code* = nullptr);
0048 _LIBCPP_EXPORTED_FROM_ABI bool __create_directory(const path&, const path& __attributes, error_code* = nullptr);
0049 _LIBCPP_EXPORTED_FROM_ABI void
0050 __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr);
0051 _LIBCPP_EXPORTED_FROM_ABI void
0052 __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
0053 _LIBCPP_EXPORTED_FROM_ABI path __current_path(error_code* __ec = nullptr);
0054 _LIBCPP_EXPORTED_FROM_ABI void __current_path(const path&, error_code* __ec = nullptr);
0055 _LIBCPP_EXPORTED_FROM_ABI bool __equivalent(const path&, const path&, error_code* __ec = nullptr);
0056 _LIBCPP_EXPORTED_FROM_ABI file_status __status(const path&, error_code* __ec = nullptr);
0057 _LIBCPP_EXPORTED_FROM_ABI uintmax_t __file_size(const path&, error_code* __ec = nullptr);
0058 _LIBCPP_EXPORTED_FROM_ABI uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);
0059 _LIBCPP_EXPORTED_FROM_ABI file_status __symlink_status(const path&, error_code* __ec = nullptr);
0060 _LIBCPP_EXPORTED_FROM_ABI file_time_type __last_write_time(const path&, error_code* __ec = nullptr);
0061 _LIBCPP_EXPORTED_FROM_ABI void __last_write_time(const path&, file_time_type __new_time, error_code* __ec = nullptr);
0062 _LIBCPP_EXPORTED_FROM_ABI path __weakly_canonical(path const& __p, error_code* __ec = nullptr);
0063 _LIBCPP_EXPORTED_FROM_ABI path __read_symlink(const path&, error_code* __ec = nullptr);
0064 _LIBCPP_EXPORTED_FROM_ABI uintmax_t __remove_all(const path&, error_code* __ec = nullptr);
0065 _LIBCPP_EXPORTED_FROM_ABI bool __remove(const path&, error_code* __ec = nullptr);
0066 _LIBCPP_EXPORTED_FROM_ABI void __rename(const path& __from, const path& __to, error_code* __ec = nullptr);
0067 _LIBCPP_EXPORTED_FROM_ABI void __resize_file(const path&, uintmax_t __size, error_code* = nullptr);
0068 _LIBCPP_EXPORTED_FROM_ABI path __temp_directory_path(error_code* __ec = nullptr);
0069
0070 inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }
0071 inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }
0072 inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); }
0073 inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); }
0074 inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) {
0075 return __copy_file(__from, __to, copy_options::none);
0076 }
0077 inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, error_code& __ec) {
0078 return __copy_file(__from, __to, copy_options::none, &__ec);
0079 }
0080 inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt) {
0081 return __copy_file(__from, __to, __opt);
0082 }
0083 inline _LIBCPP_HIDE_FROM_ABI bool
0084 copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) {
0085 return __copy_file(__from, __to, __opt, &__ec);
0086 }
0087 inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); }
0088 inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept {
0089 __copy_symlink(__from, __to, &__ec);
0090 }
0091 inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to) {
0092 __copy(__from, __to, copy_options::none);
0093 }
0094 inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, error_code& __ec) {
0095 __copy(__from, __to, copy_options::none, &__ec);
0096 }
0097 inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt) {
0098 __copy(__from, __to, __opt);
0099 }
0100 inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) {
0101 __copy(__from, __to, __opt, &__ec);
0102 }
0103 inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p) { return __create_directories(__p); }
0104 inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p, error_code& __ec) {
0105 return __create_directories(__p, &__ec);
0106 }
0107 inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link) {
0108 __create_directory_symlink(__target, __link);
0109 }
0110 inline _LIBCPP_HIDE_FROM_ABI void
0111 create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept {
0112 __create_directory_symlink(__target, __link, &__ec);
0113 }
0114 inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p) { return __create_directory(__p); }
0115 inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, error_code& __ec) noexcept {
0116 return __create_directory(__p, &__ec);
0117 }
0118 inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs) {
0119 return __create_directory(__p, __attrs);
0120 }
0121 inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept {
0122 return __create_directory(__p, __attrs, &__ec);
0123 }
0124 inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link) {
0125 __create_hard_link(__target, __link);
0126 }
0127 inline _LIBCPP_HIDE_FROM_ABI void
0128 create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept {
0129 __create_hard_link(__target, __link, &__ec);
0130 }
0131 inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link) {
0132 __create_symlink(__target, __link);
0133 }
0134 inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept {
0135 return __create_symlink(__target, __link, &__ec);
0136 }
0137 inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); }
0138 inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); }
0139 inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); }
0140 inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept {
0141 __current_path(__p, &__ec);
0142 }
0143 inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); }
0144 inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept {
0145 return __equivalent(__p1, __p2, &__ec);
0146 }
0147 inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; }
0148 inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept {
0149 return status_known(__s) && __s.type() != file_type::not_found;
0150 }
0151 inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); }
0152
0153 inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p, error_code& __ec) noexcept {
0154 auto __s = __status(__p, &__ec);
0155 if (status_known(__s))
0156 __ec.clear();
0157 return exists(__s);
0158 }
0159
0160 inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); }
0161 inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept {
0162 return __file_size(__p, &__ec);
0163 }
0164 inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); }
0165 inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept {
0166 return __hard_link_count(__p, &__ec);
0167 }
0168 inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; }
0169 inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); }
0170 inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept {
0171 return is_block_file(__status(__p, &__ec));
0172 }
0173 inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept {
0174 return __s.type() == file_type::character;
0175 }
0176 inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { return is_character_file(__status(__p)); }
0177 inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept {
0178 return is_character_file(__status(__p, &__ec));
0179 }
0180 inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; }
0181 inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); }
0182 inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept {
0183 return is_directory(__status(__p, &__ec));
0184 }
0185 _LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = nullptr);
0186 inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); }
0187 inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }
0188 inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }
0189 inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); }
0190 inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept {
0191 return is_fifo(__status(__p, &__ec));
0192 }
0193 inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; }
0194 inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); }
0195 inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept {
0196 return is_regular_file(__status(__p, &__ec));
0197 }
0198 inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; }
0199 inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); }
0200 inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept {
0201 return is_symlink(__symlink_status(__p, &__ec));
0202 }
0203 inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept {
0204 return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s);
0205 }
0206 inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); }
0207 inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept {
0208 return is_other(__status(__p, &__ec));
0209 }
0210 inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; }
0211 inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); }
0212 inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept {
0213 return is_socket(__status(__p, &__ec));
0214 }
0215 inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { return __last_write_time(__p); }
0216 inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept {
0217 return __last_write_time(__p, &__ec);
0218 }
0219 inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); }
0220 inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept {
0221 __last_write_time(__p, __t, &__ec);
0222 }
0223 _LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr);
0224 inline _LIBCPP_HIDE_FROM_ABI void
0225 permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) {
0226 __permissions(__p, __prms, __opts);
0227 }
0228 inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, error_code& __ec) noexcept {
0229 __permissions(__p, __prms, perm_options::replace, &__ec);
0230 }
0231 inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) {
0232 __permissions(__p, __prms, __opts, &__ec);
0233 }
0234
0235 inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base, error_code& __ec) {
0236 path __tmp = __weakly_canonical(__p, &__ec);
0237 if (__ec)
0238 return {};
0239 path __tmp_base = __weakly_canonical(__base, &__ec);
0240 if (__ec)
0241 return {};
0242 return __tmp.lexically_proximate(__tmp_base);
0243 }
0244
0245 inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) {
0246 return proximate(__p, current_path(), __ec);
0247 }
0248 inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) {
0249 return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base));
0250 }
0251 inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); }
0252 inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); }
0253
0254 inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base, error_code& __ec) {
0255 path __tmp = __weakly_canonical(__p, &__ec);
0256 if (__ec)
0257 return path();
0258 path __tmpbase = __weakly_canonical(__base, &__ec);
0259 if (__ec)
0260 return path();
0261 return __tmp.lexically_relative(__tmpbase);
0262 }
0263
0264 inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) {
0265 return relative(__p, current_path(), __ec);
0266 }
0267 inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) {
0268 return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base));
0269 }
0270 inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); }
0271 inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p, error_code& __ec) {
0272 return __remove_all(__p, &__ec);
0273 }
0274 inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p) { return __remove(__p); }
0275 inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); }
0276 inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to) { return __rename(__from, __to); }
0277 inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to, error_code& __ec) noexcept {
0278 return __rename(__from, __to, &__ec);
0279 }
0280 inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); }
0281 inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept {
0282 return __resize_file(__p, __ns, &__ec);
0283 }
0284 _LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr);
0285 inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); }
0286 inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept {
0287 return __space(__p, &__ec);
0288 }
0289 inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); }
0290 inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept {
0291 return __status(__p, &__ec);
0292 }
0293 inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); }
0294 inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept {
0295 return __symlink_status(__p, &__ec);
0296 }
0297 inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); }
0298 inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); }
0299 inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); }
0300 inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) {
0301 return __weakly_canonical(__p, &__ec);
0302 }
0303
0304 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
0305
0306 _LIBCPP_END_NAMESPACE_FILESYSTEM
0307
0308 #endif
0309
0310 #endif