CKTIS / C++
Filesystem and virtual filesystem
std::filesystem provides paths and filesystem operations. Distinguish a pathname from an existing file, and this library from a VFS: C++23 does not define a standard interface for plugging in custom filesystems.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
#include <filesystem>
namespace fs = std::filesystem;
fs::path p = fs::path{"assets"} / "config.txt";A filesystem is a collection of files and their attributes; a directory contains entries describing files, including other directories. The <filesystem> header provides the path type and operations such as exists, create_directories, and remove in std::filesystem. It is not an interface for reading file contents.
std::filesystem::path represents a pathname, not an open file. Constructing an object neither creates a file nor confirms its existence. The / operator composes paths; filename() and extension() extract name components. Naming rules and case sensitivity depend on the operating system.
A virtual filesystem (VFS) is an abstraction layer exposing resources as files and directories. It is not a synonym for std::filesystem: C++23 does not define an interface for registering a custom VFS backend. Do not assume that operating-system operations can handle an application resource path merely because it fits in a path.
Many operations offer a variant that throws filesystem_error and a variant taking std::error_code& to report filesystem errors. The latter is not a blanket no-exceptions guarantee. The example processes only a name and does not access the filesystem. This entry targets C++23; the supplied working draft is an evolving document, not a frozen C++23 edition.
Examples
#include <filesystem>
#include <iostream>
int main() {
namespace fs = std::filesystem;
const fs::path p = fs::path{"assets"} / "config.txt";
std::cout << p.filename().generic_string() << '\n';
std::cout << p.extension().generic_string() << '\n';
}
Result
config.txt .txt
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.