On this page
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
- Use
/operator for portable joining: Handles/vs\automatically across platforms. - Pass
std::error_code ectofs::exists/fs::removewhen you want non-throwing error handling.
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
- tuts/cpp/stdlib/io_and_filesystem Linked here; links to this page; shared tags: #cpp, #filesystem, #prog, #stdlib
- tuts/cpp/stdlib/io_and_filesystem/format_and_print Linked here; links to this page; shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/io_and_filesystem/iostream Linked here; links to this page; shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/algorithm_and_ranges/find_if shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/algorithm_and_ranges/ranges_views shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/algorithm_and_ranges/sort shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/algorithm_and_ranges/transform shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/concurrency/atomic shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/concurrency/jthread shared tags: #cpp, #prog, #stdlib, #tier
- tuts/cpp/stdlib/concurrency/mutex_and_lock_guard shared tags: #cpp, #prog, #stdlib, #tier