File class

consists of a list of strings that specify a file path when concatenated along file_sep

Could be replaced by the STL class filesystem::path, see https://en.cppreference.com/w/cpp/filesystem/path

Constructors, destructors, conversion operators

File(const std::string path = "")
standard constructor, splitting path along file_sep into a list of strings

Public functions

void create_directories() const
creates directories, if they do not exist yet
auto directories() const -> std::vector<File>
list of all parent directories and the file itself, ordered by level()
auto directory(const int& branch) const -> std::string
string obtained by concatenating the first branch-1 strings with file_sep. Results in undefined behaviour if branch is bigger than the length of the list
auto fullname() const -> std::string
concatenates all strings with file_sep. This is the inverse of the constructor.
auto is_empty() const -> bool
true if the length of the list is 0.
auto is_valid() const -> bool
true if my_alpha_num() evaluates true on every string in the list
auto level() const -> size_t
size of the list of strings
auto name() const -> std::string
returns last string in the list. We assume the list is not empty.
auto operator+(const std::string& s) const -> File
adds a string to the last element of the list
void operator+=(const std::string& s)
adds a string to the last element of the list
auto operator/(const std::string& s) const -> File
adds a string to the list
void operator/=(const std::string& s)
adds a string to the list
auto operator<(const File& file2) const -> bool
comparison operator
auto operator==(const File& file2) const -> bool
true if the two files are identical
auto parent() const -> File
returns a File obtained by removing the last element from the list (if possible)
void remove_any_extension()
removes the extension of the file, ie the first . in the last string of the list and any following character