[Branch,~jesse-barker/libmatrix/trunk] Rev 36: Add a member to Util to return just the program name from a path string.

Message ID 20120127220112.30014.50925.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker Jan. 27, 2012, 10:01 p.m.
------------------------------------------------------------
revno: 36
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Fri 2012-01-27 13:58:38 -0800
message:
  Add a member to Util to return just the program name from a path string.
modified:
  util.cc
  util.h


--
lp:libmatrix
https://code.launchpad.net/~jesse-barker/libmatrix/trunk

You are subscribed to branch lp:libmatrix.
To unsubscribe from this branch go to https://code.launchpad.net/~jesse-barker/libmatrix/trunk/+edit-subscription

Patch

=== modified file 'util.cc'
--- util.cc	2011-12-09 00:59:12 +0000
+++ util.cc	2012-01-27 21:58:38 +0000
@@ -49,6 +49,18 @@ 
     return now;
 }
 
+std::string
+Util::appname_from_path(const std::string& path)
+{
+    std::string::size_type slashPos = path.rfind("/");
+    std::string::size_type startPos(0);
+    if (slashPos != std::string::npos)
+    {
+        startPos = slashPos + 1;
+    }
+    return std::string(path, startPos, std::string::npos);
+}
+
 #ifndef ANDROID
 
 std::istream *

=== modified file 'util.h'
--- util.h	2011-12-09 00:59:12 +0000
+++ util.h	2012-01-27 21:58:38 +0000
@@ -57,7 +57,8 @@ 
         ss << t;
         return ss.str();
     }
-
+    static std::string
+    appname_from_path(const std::string& path);
 
 #ifdef ANDROID
     static void android_set_asset_manager(AAssetManager *asset_manager);