remove_all不会删除非空目录

时间:2019-06-25 11:40:58

标签: c++ boost filesystems

remove.cc

#include <string>
#include <boost/filesystem.hpp>

int main() 
{    
    std::string s = "a/b";
    boost::filesystem::remove_all(s);
    return 0;    
}

ls -R a/b
    a/b:
    c  d

./a.out 
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::remove: Directory not empty: "a"
Abort

=============================================
uintmax_t remove_all(const path& p);
uintmax_t remove_all(const path& p, system::error_code& ec);
Effects:  Recursively deletes the contents of p if it exists, then deletes         file p itself, as if by POSIX remove().
==============================================

我想念什么吗?

0 个答案:

没有答案