GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::filesystem::directory_entry::path(3) C++ Standard Libary std::filesystem::directory_entry::path(3)

std::filesystem::directory_entry::path - std::filesystem::directory_entry::path


const std::filesystem::path& path() const noexcept; (since C++17)
operator const std::filesystem::path& () const noexcept; (since C++17)


Returns the full path the directory entry refers to.


(none)


The full path the directory entry refers to.

// Run this code


#include <filesystem>
#include <fstream>
#include <iostream>


namespace fs = std::filesystem;


std::string get_stem(const fs::path &p) { return (p.stem().string()); }
void create_file(const fs::path &p) { std::ofstream o{p}; }


int main()
{
const fs::path dir{"tmp_dir"};
fs::create_directory(dir);
create_file(dir / "one");
create_file(dir / "two");
create_file(dir / "three");


for (const auto &file : fs::directory_iterator(dir)) {
// Explicit conversion
std::cout << get_stem(file.path()) << '\n';


// Implicit conversion
std::cout << get_stem(file) << '\n';
}


fs::remove_all(dir);
}


two
two
one
one
three
three


path represents a path
(C++17) (class)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.