std::filesystem::directory_entry::replace_filename
Min standard notice:
Changes the filename of the directory entry.
# Declarations
void replace_filename( const std::filesystem::path& p );
(since C++17)
void replace_filename( const std::filesystem::path& p, std::error_code& ec );
(since C++17)
# Parameters
p: the path to append to the parent path of the currently stored pathec: out-parameter for error reporting in the non-throwing overload
# Return value
(none)
# Example
#include <filesystem>
#include <iostream>
int main()
{
namespace fs = std::filesystem;
{
fs::directory_entry entry{"alpha"};
std::cout << entry << '\n';
entry.replace_filename("omega");
std::cout << entry << '\n';
}
{
fs::directory_entry entry{"/alpha/"};
std::cout << entry << '\n';
entry.replace_filename("omega");
std::cout << entry << '\n';
}
}