On this page
  1. std::filesystem::path (C++17)
  2. Overview
  3. Notes & Pitfalls
  4. Example

std::filesystem::path (C++17)

Prev: std::format & std::print | Up: io_and_filesystem | Next: std::iostream & std::fstream
Rel: std::iostream & std::fstream
Ref: cppreference — std::filesystem
Tags: #public #prog #cpp #stdlib #filesystem #tier/core


Overview

<filesystem> (C++17) provides portable path manipulation (/ operator), directory iteration, file metadata queries, and atomic-friendly file operations across POSIX and Windows.

Notes & Pitfalls

Example

#include <cassert>
#include <filesystem>

int main() {
    namespace fs = std::filesystem;
    fs::path p = fs::path("src") / "app" / "main.cpp";
    assert(p.filename() == "main.cpp" && p.extension() == ".cpp");
}

Linked from

Related notes