Create a full path in C++(17)
January 19, 2017 · 2 minutes to read · C++, C++17, Linux
Sometimes, you must create a path in an application. The main function to use on Posix is
mkdir, but it is limited to one directory.
When you want a full path like
./users/romain/tests/test1, but you do not know which parts exist, I have a function for this.
I use a new feature from C++17, called
This class as members pointing towards a string, but do not hold it. It is lighter than a full copy!
If you do not have C++17, you can easily replace a
string_view by a simple
string. All method calls stay the same.
In C++17, there is also an override for
create_directory in the namespace
I will write a most complete post on this new header.