]> git.mxchange.org Git - simgear.git/commitdiff
More SGPath APIs
authorJames Turner <zakalawe@mac.com>
Fri, 1 Jul 2016 16:14:34 +0000 (17:14 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
simgear/misc/sg_path.cxx
simgear/misc/sg_path.hxx

index efdf8438c1663b7f8c246b619cb588ca3ddb342e..067abff63ab306bcf2e6e78b6eb1b3b08bf6904e 100644 (file)
@@ -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> SGPath::pathsFromEnv(const char *name)
 
 //------------------------------------------------------------------------------
 
+std::vector<SGPath> SGPath::pathsFromUtf8(const std::string& paths)
+{
+       std::vector<SGPath> 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> SGPath::pathsFromLocal8Bit(const std::string& paths)
 {
     std::vector<SGPath> r;
index 9dc48458a51c6e0531af6934a268c8ec5f8f13e0..0fbdf44161633a32ca263b8a3f8fe7640eaa0c8b 100644 (file)
@@ -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<SGPath> pathsFromEnv(const char* name);
 
+       static std::vector<SGPath> pathsFromUtf8(const std::string& paths);
+
     static std::vector<SGPath> pathsFromLocal8Bit(const std::string& paths);
 
     static std::string join(const std::vector<SGPath>& paths, const std::string& joinWith);