| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <experimental/filesystem> | ||
bool remove(const path& p); bool remove(const path& p, error_code& ec); | (1) | (filesystem TS) |
std::uintmax_t remove_all(const path& p); std::uintmax_t remove_all(const path& p, error_code& ec); | (2) | (filesystem TS) |
Contents |
| p | - | path to delete |
| ec | - | out-parameter for error reporting in the non-throwing overload |
On POSIX systems, this function typically callsunlink andrmdir as needed, on WindowsRemoveDirectoryW andDeleteFileW.
#include <cstdint>#include <experimental/filesystem>#include <iostream>namespace fs= std::experimental::filesystem; int main(){ fs::path dir= fs::temp_directory_path(); fs::create_directories(dir/"abcdef/example");std::uintmax_t n= fs::remove_all(dir/"abcdef");std::cout<<"Deleted "<< n<<" files or directories\n";}
Possible output:
Deleted 2 files or directories
| erases a file (function)[edit] |