diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-02-20 19:41:22 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-02-20 19:41:22 +0000 |
| commit | 1872ad9888928f4bd87f4c6eee59d17a3d20ad45 (patch) | |
| tree | 1c0317bef2c44694090aef0d9720de26ca59d2df /llvm | |
| parent | cf193b83204199e1621b2bf17e4ca322bc54e3e2 (diff) | |
| download | bcm5719-llvm-1872ad9888928f4bd87f4c6eee59d17a3d20ad45.tar.gz bcm5719-llvm-1872ad9888928f4bd87f4c6eee59d17a3d20ad45.zip | |
Add convenient helper to get suffix of the file
llvm-svn: 47397
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/System/Path.h | 8 | ||||
| -rw-r--r-- | llvm/lib/System/Path.cpp | 5 |
2 files changed, 12 insertions, 1 deletions
diff --git a/llvm/include/llvm/System/Path.h b/llvm/include/llvm/System/Path.h index 3ab9e087b0c..db1de770fc2 100644 --- a/llvm/include/llvm/System/Path.h +++ b/llvm/include/llvm/System/Path.h @@ -266,6 +266,14 @@ namespace sys { /// @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. diff --git a/llvm/lib/System/Path.cpp b/llvm/lib/System/Path.cpp index 6f0667fba50..11035cfee7a 100644 --- a/llvm/lib/System/Path.cpp +++ b/llvm/lib/System/Path.cpp @@ -172,7 +172,10 @@ bool Path::hasMagicNumber(const std::string &Magic) const { 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) |

