[llvm-commits] [llvm] r47397 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Path.cpp

Anton Korobeynikov asl at math.spbu.ru
Wed Feb 20 11:41:22 PST 2008


Author: asl
Date: Wed Feb 20 13:41:22 2008
New Revision: 47397

URL: http://llvm.org/viewvc/llvm-project?rev=47397&view=rev
Log:
Add convenient helper to get suffix of the file

Modified:
    llvm/trunk/include/llvm/System/Path.h
    llvm/trunk/lib/System/Path.cpp

Modified: llvm/trunk/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=47397&r1=47396&r2=47397&view=diff

==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Wed Feb 20 13:41:22 2008
@@ -266,6 +266,14 @@
       /// @brief Get the base name of the path
       std::string getBasename() const;
 
+      /// This function strips off the path and basename(up to and
+      /// including the last dot) of the file or directory name and
+      /// returns just the suffix. For example /a/foo.bar would cause
+      /// this function to return "bar".
+      /// @returns std::string containing the suffix of the path
+      /// @brief Get the suffix of the path
+      std::string getSuffix() const;
+
       /// Obtain a 'C' string for the path name.
       /// @returns a 'C' string containing the path name.
       /// @brief Returns the path as a C string.

Modified: llvm/trunk/lib/System/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=47397&r1=47396&r2=47397&view=diff

==============================================================================
--- llvm/trunk/lib/System/Path.cpp (original)
+++ llvm/trunk/lib/System/Path.cpp Wed Feb 20 13:41:22 2008
@@ -172,7 +172,10 @@
   return false;
 }
 
-
+std::string
+Path::getSuffix() const {
+  return path.substr(path.rfind('.') + 1);
+}
 
 // Include the truly platform-specific parts of this class.
 #if defined(LLVM_ON_UNIX)





More information about the llvm-commits mailing list