Representing paths in C++
Throughout Chapter 9, Iostreams, every function that expected a "filename" (that is, a path) as a parameter was happy to take that path as a simple const char *. But in the <filesystem> library, we're going to complicate that picture, all because of Windows.
All POSIX filesystems store names (like speech.txt) as simple raw byte strings. The only rules in POSIX are that your names can't contain '\0', and your names can't contain '/' (because that's the character we're going to split on). On POSIX, "\xC1.h" is a perfectly valid filename, despite the fact that it is not valid UTF-8 and not valid ASCII, and the way it'll display on your screen when you ls . is completely dependent on your current locale and codepage. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access