1*0eae32dcSDimitry Andric // -*- C++ -*- 2*0eae32dcSDimitry Andric //===----------------------------------------------------------------------===// 3*0eae32dcSDimitry Andric // 4*0eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*0eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 6*0eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*0eae32dcSDimitry Andric // 8*0eae32dcSDimitry Andric //===----------------------------------------------------------------------===// 9*0eae32dcSDimitry Andric 10*0eae32dcSDimitry Andric #ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H 11*0eae32dcSDimitry Andric #define _LIBCPP___FILESYSTEM_OPERATIONS_H 12*0eae32dcSDimitry Andric 13*0eae32dcSDimitry Andric #include <__availability> 14*0eae32dcSDimitry Andric #include <__config> 15*0eae32dcSDimitry Andric #include <__filesystem/copy_options.h> 16*0eae32dcSDimitry Andric #include <__filesystem/file_status.h> 17*0eae32dcSDimitry Andric #include <__filesystem/file_time_type.h> 18*0eae32dcSDimitry Andric #include <__filesystem/file_type.h> 19*0eae32dcSDimitry Andric #include <__filesystem/path.h> 20*0eae32dcSDimitry Andric #include <__filesystem/perm_options.h> 21*0eae32dcSDimitry Andric #include <__filesystem/perms.h> 22*0eae32dcSDimitry Andric #include <__filesystem/space_info.h> 23*0eae32dcSDimitry Andric #include <chrono> 24*0eae32dcSDimitry Andric #include <cstdint> 25*0eae32dcSDimitry Andric #include <system_error> 26*0eae32dcSDimitry Andric 27*0eae32dcSDimitry Andric #ifndef _LIBCPP_CXX03_LANG 28*0eae32dcSDimitry Andric 29*0eae32dcSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM 30*0eae32dcSDimitry Andric 31*0eae32dcSDimitry Andric _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH 32*0eae32dcSDimitry Andric 33*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 34*0eae32dcSDimitry Andric path __absolute(const path&, error_code* __ec = nullptr); 35*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 36*0eae32dcSDimitry Andric path __canonical(const path&, error_code* __ec = nullptr); 37*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 38*0eae32dcSDimitry Andric bool __copy_file(const path& __from, const path& __to, copy_options __opt, 39*0eae32dcSDimitry Andric error_code* __ec = nullptr); 40*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 41*0eae32dcSDimitry Andric void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, 42*0eae32dcSDimitry Andric error_code* __ec = nullptr); 43*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 44*0eae32dcSDimitry Andric void __copy(const path& __from, const path& __to, copy_options __opt, 45*0eae32dcSDimitry Andric error_code* __ec = nullptr); 46*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 47*0eae32dcSDimitry Andric bool __create_directories(const path& p, error_code* ec = nullptr); 48*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 49*0eae32dcSDimitry Andric void __create_directory_symlink(const path& __to, const path& __new_symlink, 50*0eae32dcSDimitry Andric error_code* __ec = nullptr); 51*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 52*0eae32dcSDimitry Andric bool __create_directory(const path& p, error_code* ec = nullptr); 53*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 54*0eae32dcSDimitry Andric bool __create_directory(const path& p, const path& attributes, 55*0eae32dcSDimitry Andric error_code* ec = nullptr); 56*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 57*0eae32dcSDimitry Andric void __create_hard_link(const path& __to, const path& __new_hard_link, 58*0eae32dcSDimitry Andric error_code* __ec = nullptr); 59*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 60*0eae32dcSDimitry Andric void __create_symlink(const path& __to, const path& __new_symlink, 61*0eae32dcSDimitry Andric error_code* __ec = nullptr); 62*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 63*0eae32dcSDimitry Andric path __current_path(error_code* __ec = nullptr); 64*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 65*0eae32dcSDimitry Andric void __current_path(const path&, error_code* __ec = nullptr); 66*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 67*0eae32dcSDimitry Andric bool __equivalent(const path&, const path&, error_code* __ec = nullptr); 68*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 69*0eae32dcSDimitry Andric file_status __status(const path&, error_code* __ec = nullptr); 70*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 71*0eae32dcSDimitry Andric uintmax_t __file_size(const path&, error_code* __ec = nullptr); 72*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 73*0eae32dcSDimitry Andric uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr); 74*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 75*0eae32dcSDimitry Andric file_status __symlink_status(const path&, error_code* __ec = nullptr); 76*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 77*0eae32dcSDimitry Andric file_time_type __last_write_time(const path& p, error_code* ec = nullptr); 78*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 79*0eae32dcSDimitry Andric void __last_write_time(const path& p, file_time_type new_time, 80*0eae32dcSDimitry Andric error_code* ec = nullptr); 81*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 82*0eae32dcSDimitry Andric path __weakly_canonical(path const& __p, error_code* __ec = nullptr); 83*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 84*0eae32dcSDimitry Andric path __read_symlink(const path& p, error_code* ec = nullptr); 85*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 86*0eae32dcSDimitry Andric uintmax_t __remove_all(const path& p, error_code* ec = nullptr); 87*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 88*0eae32dcSDimitry Andric bool __remove(const path& p, error_code* ec = nullptr); 89*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 90*0eae32dcSDimitry Andric void __rename(const path& from, const path& to, error_code* ec = nullptr); 91*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 92*0eae32dcSDimitry Andric void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr); 93*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 94*0eae32dcSDimitry Andric path __temp_directory_path(error_code* __ec = nullptr); 95*0eae32dcSDimitry Andric 96*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { 97*0eae32dcSDimitry Andric return __absolute(__p); 98*0eae32dcSDimitry Andric } 99*0eae32dcSDimitry Andric 100*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, 101*0eae32dcSDimitry Andric error_code& __ec) { 102*0eae32dcSDimitry Andric return __absolute(__p, &__ec); 103*0eae32dcSDimitry Andric } 104*0eae32dcSDimitry Andric 105*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { 106*0eae32dcSDimitry Andric return __canonical(__p); 107*0eae32dcSDimitry Andric } 108*0eae32dcSDimitry Andric 109*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, 110*0eae32dcSDimitry Andric error_code& __ec) { 111*0eae32dcSDimitry Andric return __canonical(__p, &__ec); 112*0eae32dcSDimitry Andric } 113*0eae32dcSDimitry Andric 114*0eae32dcSDimitry Andric 115*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, 116*0eae32dcSDimitry Andric const path& __to) { 117*0eae32dcSDimitry Andric return __copy_file(__from, __to, copy_options::none); 118*0eae32dcSDimitry Andric } 119*0eae32dcSDimitry Andric 120*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 121*0eae32dcSDimitry Andric copy_file(const path& __from, const path& __to, error_code& __ec) { 122*0eae32dcSDimitry Andric return __copy_file(__from, __to, copy_options::none, &__ec); 123*0eae32dcSDimitry Andric } 124*0eae32dcSDimitry Andric 125*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 126*0eae32dcSDimitry Andric copy_file(const path& __from, const path& __to, copy_options __opt) { 127*0eae32dcSDimitry Andric return __copy_file(__from, __to, __opt); 128*0eae32dcSDimitry Andric } 129*0eae32dcSDimitry Andric 130*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, 131*0eae32dcSDimitry Andric const path& __to, 132*0eae32dcSDimitry Andric copy_options __opt, 133*0eae32dcSDimitry Andric error_code& __ec) { 134*0eae32dcSDimitry Andric return __copy_file(__from, __to, __opt, &__ec); 135*0eae32dcSDimitry Andric } 136*0eae32dcSDimitry Andric 137*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __existing, 138*0eae32dcSDimitry Andric const path& __new) { 139*0eae32dcSDimitry Andric __copy_symlink(__existing, __new); 140*0eae32dcSDimitry Andric } 141*0eae32dcSDimitry Andric 142*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 143*0eae32dcSDimitry Andric copy_symlink(const path& __ext, const path& __new, error_code& __ec) noexcept { 144*0eae32dcSDimitry Andric __copy_symlink(__ext, __new, &__ec); 145*0eae32dcSDimitry Andric } 146*0eae32dcSDimitry Andric 147*0eae32dcSDimitry Andric 148*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, 149*0eae32dcSDimitry Andric const path& __to) { 150*0eae32dcSDimitry Andric __copy(__from, __to, copy_options::none); 151*0eae32dcSDimitry Andric } 152*0eae32dcSDimitry Andric 153*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, 154*0eae32dcSDimitry Andric error_code& __ec) { 155*0eae32dcSDimitry Andric __copy(__from, __to, copy_options::none, &__ec); 156*0eae32dcSDimitry Andric } 157*0eae32dcSDimitry Andric 158*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, 159*0eae32dcSDimitry Andric copy_options __opt) { 160*0eae32dcSDimitry Andric __copy(__from, __to, __opt); 161*0eae32dcSDimitry Andric } 162*0eae32dcSDimitry Andric 163*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, 164*0eae32dcSDimitry Andric copy_options __opt, 165*0eae32dcSDimitry Andric error_code& __ec) { 166*0eae32dcSDimitry Andric __copy(__from, __to, __opt, &__ec); 167*0eae32dcSDimitry Andric } 168*0eae32dcSDimitry Andric 169*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { 170*0eae32dcSDimitry Andric return __create_directories(__p); 171*0eae32dcSDimitry Andric } 172*0eae32dcSDimitry Andric 173*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, 174*0eae32dcSDimitry Andric error_code& __ec) { 175*0eae32dcSDimitry Andric return __create_directories(__p, &__ec); 176*0eae32dcSDimitry Andric } 177*0eae32dcSDimitry Andric 178*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 179*0eae32dcSDimitry Andric create_directory_symlink(const path& __to, const path& __new) { 180*0eae32dcSDimitry Andric __create_directory_symlink(__to, __new); 181*0eae32dcSDimitry Andric } 182*0eae32dcSDimitry Andric 183*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 184*0eae32dcSDimitry Andric create_directory_symlink(const path& __to, const path& __new, 185*0eae32dcSDimitry Andric error_code& __ec) noexcept { 186*0eae32dcSDimitry Andric __create_directory_symlink(__to, __new, &__ec); 187*0eae32dcSDimitry Andric } 188*0eae32dcSDimitry Andric 189*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { 190*0eae32dcSDimitry Andric return __create_directory(__p); 191*0eae32dcSDimitry Andric } 192*0eae32dcSDimitry Andric 193*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 194*0eae32dcSDimitry Andric create_directory(const path& __p, error_code& __ec) noexcept { 195*0eae32dcSDimitry Andric return __create_directory(__p, &__ec); 196*0eae32dcSDimitry Andric } 197*0eae32dcSDimitry Andric 198*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, 199*0eae32dcSDimitry Andric const path& __attrs) { 200*0eae32dcSDimitry Andric return __create_directory(__p, __attrs); 201*0eae32dcSDimitry Andric } 202*0eae32dcSDimitry Andric 203*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 204*0eae32dcSDimitry Andric create_directory(const path& __p, const path& __attrs, 205*0eae32dcSDimitry Andric error_code& __ec) noexcept { 206*0eae32dcSDimitry Andric return __create_directory(__p, __attrs, &__ec); 207*0eae32dcSDimitry Andric } 208*0eae32dcSDimitry Andric 209*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __to, 210*0eae32dcSDimitry Andric const path& __new) { 211*0eae32dcSDimitry Andric __create_hard_link(__to, __new); 212*0eae32dcSDimitry Andric } 213*0eae32dcSDimitry Andric 214*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 215*0eae32dcSDimitry Andric create_hard_link(const path& __to, const path& __new, 216*0eae32dcSDimitry Andric error_code& __ec) noexcept { 217*0eae32dcSDimitry Andric __create_hard_link(__to, __new, &__ec); 218*0eae32dcSDimitry Andric } 219*0eae32dcSDimitry Andric 220*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __to, 221*0eae32dcSDimitry Andric const path& __new) { 222*0eae32dcSDimitry Andric __create_symlink(__to, __new); 223*0eae32dcSDimitry Andric } 224*0eae32dcSDimitry Andric 225*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 226*0eae32dcSDimitry Andric create_symlink(const path& __to, const path& __new, error_code& __ec) noexcept { 227*0eae32dcSDimitry Andric return __create_symlink(__to, __new, &__ec); 228*0eae32dcSDimitry Andric } 229*0eae32dcSDimitry Andric 230*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path current_path() { 231*0eae32dcSDimitry Andric return __current_path(); 232*0eae32dcSDimitry Andric } 233*0eae32dcSDimitry Andric 234*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { 235*0eae32dcSDimitry Andric return __current_path(&__ec); 236*0eae32dcSDimitry Andric } 237*0eae32dcSDimitry Andric 238*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { 239*0eae32dcSDimitry Andric __current_path(__p); 240*0eae32dcSDimitry Andric } 241*0eae32dcSDimitry Andric 242*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, 243*0eae32dcSDimitry Andric error_code& __ec) noexcept { 244*0eae32dcSDimitry Andric __current_path(__p, &__ec); 245*0eae32dcSDimitry Andric } 246*0eae32dcSDimitry Andric 247*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, 248*0eae32dcSDimitry Andric const path& __p2) { 249*0eae32dcSDimitry Andric return __equivalent(__p1, __p2); 250*0eae32dcSDimitry Andric } 251*0eae32dcSDimitry Andric 252*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 253*0eae32dcSDimitry Andric equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { 254*0eae32dcSDimitry Andric return __equivalent(__p1, __p2, &__ec); 255*0eae32dcSDimitry Andric } 256*0eae32dcSDimitry Andric 257*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { 258*0eae32dcSDimitry Andric return __s.type() != file_type::none; 259*0eae32dcSDimitry Andric } 260*0eae32dcSDimitry Andric 261*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { 262*0eae32dcSDimitry Andric return status_known(__s) && __s.type() != file_type::not_found; 263*0eae32dcSDimitry Andric } 264*0eae32dcSDimitry Andric 265*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { 266*0eae32dcSDimitry Andric return exists(__status(__p)); 267*0eae32dcSDimitry Andric } 268*0eae32dcSDimitry Andric 269*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, 270*0eae32dcSDimitry Andric error_code& __ec) noexcept { 271*0eae32dcSDimitry Andric auto __s = __status(__p, &__ec); 272*0eae32dcSDimitry Andric if (status_known(__s)) 273*0eae32dcSDimitry Andric __ec.clear(); 274*0eae32dcSDimitry Andric return exists(__s); 275*0eae32dcSDimitry Andric } 276*0eae32dcSDimitry Andric 277*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { 278*0eae32dcSDimitry Andric return __file_size(__p); 279*0eae32dcSDimitry Andric } 280*0eae32dcSDimitry Andric 281*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY uintmax_t 282*0eae32dcSDimitry Andric file_size(const path& __p, error_code& __ec) noexcept { 283*0eae32dcSDimitry Andric return __file_size(__p, &__ec); 284*0eae32dcSDimitry Andric } 285*0eae32dcSDimitry Andric 286*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { 287*0eae32dcSDimitry Andric return __hard_link_count(__p); 288*0eae32dcSDimitry Andric } 289*0eae32dcSDimitry Andric 290*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY uintmax_t 291*0eae32dcSDimitry Andric hard_link_count(const path& __p, error_code& __ec) noexcept { 292*0eae32dcSDimitry Andric return __hard_link_count(__p, &__ec); 293*0eae32dcSDimitry Andric } 294*0eae32dcSDimitry Andric 295*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { 296*0eae32dcSDimitry Andric return __s.type() == file_type::block; 297*0eae32dcSDimitry Andric } 298*0eae32dcSDimitry Andric 299*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { 300*0eae32dcSDimitry Andric return is_block_file(__status(__p)); 301*0eae32dcSDimitry Andric } 302*0eae32dcSDimitry Andric 303*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, 304*0eae32dcSDimitry Andric error_code& __ec) noexcept { 305*0eae32dcSDimitry Andric return is_block_file(__status(__p, &__ec)); 306*0eae32dcSDimitry Andric } 307*0eae32dcSDimitry Andric 308*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 309*0eae32dcSDimitry Andric is_character_file(file_status __s) noexcept { 310*0eae32dcSDimitry Andric return __s.type() == file_type::character; 311*0eae32dcSDimitry Andric } 312*0eae32dcSDimitry Andric 313*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { 314*0eae32dcSDimitry Andric return is_character_file(__status(__p)); 315*0eae32dcSDimitry Andric } 316*0eae32dcSDimitry Andric 317*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 318*0eae32dcSDimitry Andric is_character_file(const path& __p, error_code& __ec) noexcept { 319*0eae32dcSDimitry Andric return is_character_file(__status(__p, &__ec)); 320*0eae32dcSDimitry Andric } 321*0eae32dcSDimitry Andric 322*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { 323*0eae32dcSDimitry Andric return __s.type() == file_type::directory; 324*0eae32dcSDimitry Andric } 325*0eae32dcSDimitry Andric 326*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { 327*0eae32dcSDimitry Andric return is_directory(__status(__p)); 328*0eae32dcSDimitry Andric } 329*0eae32dcSDimitry Andric 330*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p, 331*0eae32dcSDimitry Andric error_code& __ec) noexcept { 332*0eae32dcSDimitry Andric return is_directory(__status(__p, &__ec)); 333*0eae32dcSDimitry Andric } 334*0eae32dcSDimitry Andric 335*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 336*0eae32dcSDimitry Andric bool __fs_is_empty(const path& p, error_code* ec = nullptr); 337*0eae32dcSDimitry Andric 338*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { 339*0eae32dcSDimitry Andric return __fs_is_empty(__p); 340*0eae32dcSDimitry Andric } 341*0eae32dcSDimitry Andric 342*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, 343*0eae32dcSDimitry Andric error_code& __ec) { 344*0eae32dcSDimitry Andric return __fs_is_empty(__p, &__ec); 345*0eae32dcSDimitry Andric } 346*0eae32dcSDimitry Andric 347*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { 348*0eae32dcSDimitry Andric return __s.type() == file_type::fifo; 349*0eae32dcSDimitry Andric } 350*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { 351*0eae32dcSDimitry Andric return is_fifo(__status(__p)); 352*0eae32dcSDimitry Andric } 353*0eae32dcSDimitry Andric 354*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, 355*0eae32dcSDimitry Andric error_code& __ec) noexcept { 356*0eae32dcSDimitry Andric return is_fifo(__status(__p, &__ec)); 357*0eae32dcSDimitry Andric } 358*0eae32dcSDimitry Andric 359*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 360*0eae32dcSDimitry Andric is_regular_file(file_status __s) noexcept { 361*0eae32dcSDimitry Andric return __s.type() == file_type::regular; 362*0eae32dcSDimitry Andric } 363*0eae32dcSDimitry Andric 364*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { 365*0eae32dcSDimitry Andric return is_regular_file(__status(__p)); 366*0eae32dcSDimitry Andric } 367*0eae32dcSDimitry Andric 368*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool 369*0eae32dcSDimitry Andric is_regular_file(const path& __p, error_code& __ec) noexcept { 370*0eae32dcSDimitry Andric return is_regular_file(__status(__p, &__ec)); 371*0eae32dcSDimitry Andric } 372*0eae32dcSDimitry Andric 373*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { 374*0eae32dcSDimitry Andric return __s.type() == file_type::symlink; 375*0eae32dcSDimitry Andric } 376*0eae32dcSDimitry Andric 377*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { 378*0eae32dcSDimitry Andric return is_symlink(__symlink_status(__p)); 379*0eae32dcSDimitry Andric } 380*0eae32dcSDimitry Andric 381*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, 382*0eae32dcSDimitry Andric error_code& __ec) noexcept { 383*0eae32dcSDimitry Andric return is_symlink(__symlink_status(__p, &__ec)); 384*0eae32dcSDimitry Andric } 385*0eae32dcSDimitry Andric 386*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { 387*0eae32dcSDimitry Andric return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && 388*0eae32dcSDimitry Andric !is_symlink(__s); 389*0eae32dcSDimitry Andric } 390*0eae32dcSDimitry Andric 391*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { 392*0eae32dcSDimitry Andric return is_other(__status(__p)); 393*0eae32dcSDimitry Andric } 394*0eae32dcSDimitry Andric 395*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, 396*0eae32dcSDimitry Andric error_code& __ec) noexcept { 397*0eae32dcSDimitry Andric return is_other(__status(__p, &__ec)); 398*0eae32dcSDimitry Andric } 399*0eae32dcSDimitry Andric 400*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { 401*0eae32dcSDimitry Andric return __s.type() == file_type::socket; 402*0eae32dcSDimitry Andric } 403*0eae32dcSDimitry Andric 404*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { 405*0eae32dcSDimitry Andric return is_socket(__status(__p)); 406*0eae32dcSDimitry Andric } 407*0eae32dcSDimitry Andric 408*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, 409*0eae32dcSDimitry Andric error_code& __ec) noexcept { 410*0eae32dcSDimitry Andric return is_socket(__status(__p, &__ec)); 411*0eae32dcSDimitry Andric } 412*0eae32dcSDimitry Andric 413*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY file_time_type 414*0eae32dcSDimitry Andric last_write_time(const path& __p) { 415*0eae32dcSDimitry Andric return __last_write_time(__p); 416*0eae32dcSDimitry Andric } 417*0eae32dcSDimitry Andric 418*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY file_time_type 419*0eae32dcSDimitry Andric last_write_time(const path& __p, error_code& __ec) noexcept { 420*0eae32dcSDimitry Andric return __last_write_time(__p, &__ec); 421*0eae32dcSDimitry Andric } 422*0eae32dcSDimitry Andric 423*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, 424*0eae32dcSDimitry Andric file_time_type __t) { 425*0eae32dcSDimitry Andric __last_write_time(__p, __t); 426*0eae32dcSDimitry Andric } 427*0eae32dcSDimitry Andric 428*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 429*0eae32dcSDimitry Andric last_write_time(const path& __p, file_time_type __t, 430*0eae32dcSDimitry Andric error_code& __ec) noexcept { 431*0eae32dcSDimitry Andric __last_write_time(__p, __t, &__ec); 432*0eae32dcSDimitry Andric } 433*0eae32dcSDimitry Andric 434*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 435*0eae32dcSDimitry Andric void __permissions(const path&, perms, perm_options, error_code* = nullptr); 436*0eae32dcSDimitry Andric 437*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 438*0eae32dcSDimitry Andric permissions(const path& __p, perms __prms, 439*0eae32dcSDimitry Andric perm_options __opts = perm_options::replace) { 440*0eae32dcSDimitry Andric __permissions(__p, __prms, __opts); 441*0eae32dcSDimitry Andric } 442*0eae32dcSDimitry Andric 443*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, 444*0eae32dcSDimitry Andric error_code& __ec) noexcept { 445*0eae32dcSDimitry Andric __permissions(__p, __prms, perm_options::replace, &__ec); 446*0eae32dcSDimitry Andric } 447*0eae32dcSDimitry Andric 448*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, 449*0eae32dcSDimitry Andric perm_options __opts, 450*0eae32dcSDimitry Andric error_code& __ec) { 451*0eae32dcSDimitry Andric __permissions(__p, __prms, __opts, &__ec); 452*0eae32dcSDimitry Andric } 453*0eae32dcSDimitry Andric 454*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, 455*0eae32dcSDimitry Andric const path& __base, 456*0eae32dcSDimitry Andric error_code& __ec) { 457*0eae32dcSDimitry Andric path __tmp = __weakly_canonical(__p, &__ec); 458*0eae32dcSDimitry Andric if (__ec) 459*0eae32dcSDimitry Andric return {}; 460*0eae32dcSDimitry Andric path __tmp_base = __weakly_canonical(__base, &__ec); 461*0eae32dcSDimitry Andric if (__ec) 462*0eae32dcSDimitry Andric return {}; 463*0eae32dcSDimitry Andric return __tmp.lexically_proximate(__tmp_base); 464*0eae32dcSDimitry Andric } 465*0eae32dcSDimitry Andric 466*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, 467*0eae32dcSDimitry Andric error_code& __ec) { 468*0eae32dcSDimitry Andric return proximate(__p, current_path(), __ec); 469*0eae32dcSDimitry Andric } 470*0eae32dcSDimitry Andric 471*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path 472*0eae32dcSDimitry Andric proximate(const path& __p, const path& __base = current_path()) { 473*0eae32dcSDimitry Andric return __weakly_canonical(__p).lexically_proximate( 474*0eae32dcSDimitry Andric __weakly_canonical(__base)); 475*0eae32dcSDimitry Andric } 476*0eae32dcSDimitry Andric 477*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { 478*0eae32dcSDimitry Andric return __read_symlink(__p); 479*0eae32dcSDimitry Andric } 480*0eae32dcSDimitry Andric 481*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, 482*0eae32dcSDimitry Andric error_code& __ec) { 483*0eae32dcSDimitry Andric return __read_symlink(__p, &__ec); 484*0eae32dcSDimitry Andric } 485*0eae32dcSDimitry Andric 486*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, 487*0eae32dcSDimitry Andric const path& __base, 488*0eae32dcSDimitry Andric error_code& __ec) { 489*0eae32dcSDimitry Andric path __tmp = __weakly_canonical(__p, &__ec); 490*0eae32dcSDimitry Andric if (__ec) 491*0eae32dcSDimitry Andric return path(); 492*0eae32dcSDimitry Andric path __tmpbase = __weakly_canonical(__base, &__ec); 493*0eae32dcSDimitry Andric if (__ec) 494*0eae32dcSDimitry Andric return path(); 495*0eae32dcSDimitry Andric return __tmp.lexically_relative(__tmpbase); 496*0eae32dcSDimitry Andric } 497*0eae32dcSDimitry Andric 498*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, 499*0eae32dcSDimitry Andric error_code& __ec) { 500*0eae32dcSDimitry Andric return relative(__p, current_path(), __ec); 501*0eae32dcSDimitry Andric } 502*0eae32dcSDimitry Andric 503*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path 504*0eae32dcSDimitry Andric relative(const path& __p, const path& __base = current_path()) { 505*0eae32dcSDimitry Andric return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); 506*0eae32dcSDimitry Andric } 507*0eae32dcSDimitry Andric 508*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { 509*0eae32dcSDimitry Andric return __remove_all(__p); 510*0eae32dcSDimitry Andric } 511*0eae32dcSDimitry Andric 512*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, 513*0eae32dcSDimitry Andric error_code& __ec) { 514*0eae32dcSDimitry Andric return __remove_all(__p, &__ec); 515*0eae32dcSDimitry Andric } 516*0eae32dcSDimitry Andric 517*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { 518*0eae32dcSDimitry Andric return __remove(__p); 519*0eae32dcSDimitry Andric } 520*0eae32dcSDimitry Andric 521*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, 522*0eae32dcSDimitry Andric error_code& __ec) noexcept { 523*0eae32dcSDimitry Andric return __remove(__p, &__ec); 524*0eae32dcSDimitry Andric } 525*0eae32dcSDimitry Andric 526*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, 527*0eae32dcSDimitry Andric const path& __to) { 528*0eae32dcSDimitry Andric return __rename(__from, __to); 529*0eae32dcSDimitry Andric } 530*0eae32dcSDimitry Andric 531*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 532*0eae32dcSDimitry Andric rename(const path& __from, const path& __to, error_code& __ec) noexcept { 533*0eae32dcSDimitry Andric return __rename(__from, __to, &__ec); 534*0eae32dcSDimitry Andric } 535*0eae32dcSDimitry Andric 536*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, 537*0eae32dcSDimitry Andric uintmax_t __ns) { 538*0eae32dcSDimitry Andric return __resize_file(__p, __ns); 539*0eae32dcSDimitry Andric } 540*0eae32dcSDimitry Andric 541*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY void 542*0eae32dcSDimitry Andric resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { 543*0eae32dcSDimitry Andric return __resize_file(__p, __ns, &__ec); 544*0eae32dcSDimitry Andric } 545*0eae32dcSDimitry Andric 546*0eae32dcSDimitry Andric _LIBCPP_FUNC_VIS 547*0eae32dcSDimitry Andric space_info __space(const path&, error_code* __ec = nullptr); 548*0eae32dcSDimitry Andric 549*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { 550*0eae32dcSDimitry Andric return __space(__p); 551*0eae32dcSDimitry Andric } 552*0eae32dcSDimitry Andric 553*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, 554*0eae32dcSDimitry Andric error_code& __ec) noexcept { 555*0eae32dcSDimitry Andric return __space(__p, &__ec); 556*0eae32dcSDimitry Andric } 557*0eae32dcSDimitry Andric 558*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { 559*0eae32dcSDimitry Andric return __status(__p); 560*0eae32dcSDimitry Andric } 561*0eae32dcSDimitry Andric 562*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, 563*0eae32dcSDimitry Andric error_code& __ec) noexcept { 564*0eae32dcSDimitry Andric return __status(__p, &__ec); 565*0eae32dcSDimitry Andric } 566*0eae32dcSDimitry Andric 567*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { 568*0eae32dcSDimitry Andric return __symlink_status(__p); 569*0eae32dcSDimitry Andric } 570*0eae32dcSDimitry Andric 571*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY file_status 572*0eae32dcSDimitry Andric symlink_status(const path& __p, error_code& __ec) noexcept { 573*0eae32dcSDimitry Andric return __symlink_status(__p, &__ec); 574*0eae32dcSDimitry Andric } 575*0eae32dcSDimitry Andric 576*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { 577*0eae32dcSDimitry Andric return __temp_directory_path(); 578*0eae32dcSDimitry Andric } 579*0eae32dcSDimitry Andric 580*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { 581*0eae32dcSDimitry Andric return __temp_directory_path(&__ec); 582*0eae32dcSDimitry Andric } 583*0eae32dcSDimitry Andric 584*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { 585*0eae32dcSDimitry Andric return __weakly_canonical(__p); 586*0eae32dcSDimitry Andric } 587*0eae32dcSDimitry Andric 588*0eae32dcSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, 589*0eae32dcSDimitry Andric error_code& __ec) { 590*0eae32dcSDimitry Andric return __weakly_canonical(__p, &__ec); 591*0eae32dcSDimitry Andric } 592*0eae32dcSDimitry Andric 593*0eae32dcSDimitry Andric _LIBCPP_AVAILABILITY_FILESYSTEM_POP 594*0eae32dcSDimitry Andric 595*0eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_FILESYSTEM 596*0eae32dcSDimitry Andric 597*0eae32dcSDimitry Andric #endif // _LIBCPP_CXX03_LANG 598*0eae32dcSDimitry Andric 599*0eae32dcSDimitry Andric #endif // _LIBCPP___FILESYSTEM_OPERATIONS_H 600