From: James Turner Date: Fri, 1 Jul 2016 16:14:34 +0000 (+0100) Subject: More SGPath APIs X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=db177a0b29aaca7e7ed38eb069b30c513e9317b5;p=simgear.git More SGPath APIs --- diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx index efdf8438..067abff6 100644 --- a/simgear/misc/sg_path.cxx +++ b/simgear/misc/sg_path.cxx @@ -374,6 +374,11 @@ string SGPath::dir() const { } } +SGPath SGPath::dirPath() const +{ + return SGPath::fromUtf8(dir()); +} + // get the base part of the path (everything but the extension.) string SGPath::base() const { @@ -871,6 +876,20 @@ std::vector SGPath::pathsFromEnv(const char *name) //------------------------------------------------------------------------------ +std::vector SGPath::pathsFromUtf8(const std::string& paths) +{ + std::vector r; + string_list items = sgPathSplit(paths); + string_list_iterator it; + for (it = items.begin(); it != items.end(); ++it) { + r.push_back(SGPath::fromUtf8(it->c_str())); + } + + return r; +} + +//------------------------------------------------------------------------------ + std::vector SGPath::pathsFromLocal8Bit(const std::string& paths) { std::vector r; diff --git a/simgear/misc/sg_path.hxx b/simgear/misc/sg_path.hxx index 9dc48458..0fbdf441 100644 --- a/simgear/misc/sg_path.hxx +++ b/simgear/misc/sg_path.hxx @@ -268,6 +268,12 @@ public: * or if the destination already exists, or is not writeable */ bool rename(const SGPath& newName); + + + /** + * return the path of the parent directory of this path. + */ + SGPath dirPath() const; enum StandardLocation { @@ -311,6 +317,8 @@ public: static std::vector pathsFromEnv(const char* name); + static std::vector pathsFromUtf8(const std::string& paths); + static std::vector pathsFromLocal8Bit(const std::string& paths); static std::string join(const std::vector& paths, const std::string& joinWith);