Class strpath_manip

Class Documentation

class legion::core::filesystem::strpath_manip

Public Static Functions

static std::string parent(const std::string &p)

gets parent directory

Return

std::string path to parent directory

Parameters
  • [in] p: the path you want the parent of

static std::string subdir(const std::string &p, const std::string &sub)

gets a subdirectory

Return

std::string path + subdirectory

Parameters
  • [in] p: the path you want to join with a subdirectory

  • [in] sub: the subdirectory of the path

static std::string sanitize(const std::string &p, bool fail_on_fs_leave = false)

sanitizes a path

Return

std::string the sanitized path

Note

what does this do ? this will reduce surplus .. and . from the path, for example: ../cool_directory/no_so_cool_directory/./../hello_world becomes ../cool_directory/hello_world

Parameters
  • [in] p: the path to sanitize

  • [in] fail_on_fs_leave: when true the operation will return an empty string when the filesystem terminates with ..

static std::string localize(const std::string &p)

makes a path “native” to the operating system

Return

std::string the tranlsated path

Note

what does this do ? this will turn / into \ and \ into / depending on your os, for example: C:/hello_world\what/is\up becomes C:\hello_world\what\is\up (if your host is windows)

Parameters
  • [in] p: the path you want to translate

static std::string &inline_localize(std::string &p)

does the same as localize but without creating a new string

Return

std::string& ref to p

Parameters
  • [in/out]: p the string you want to translate

static inline constexpr static char separator ()

gets the path separator that is “native” to the operating system