diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-06-15 15:15:19 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-06-15 15:15:19 +0000 |
| commit | 2cc0abf260b4acb66535a386efe4cb8868e15da6 (patch) | |
| tree | dfd56cb1dde1924e471d973c827bfdf95584d12a /llvm/lib/System/Unix | |
| parent | cb16b095c5e9c1cbcd96f643d193f630e3ac6c49 (diff) | |
| download | bcm5719-llvm-2cc0abf260b4acb66535a386efe4cb8868e15da6.tar.gz bcm5719-llvm-2cc0abf260b4acb66535a386efe4cb8868e15da6.zip | |
Fix the sys::Path::getSuffix() implementation.
llvm-svn: 52288
Diffstat (limited to 'llvm/lib/System/Unix')
| -rw-r--r-- | llvm/lib/System/Unix/Path.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index 6035a14d27a..5b91b038d43 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -303,6 +303,22 @@ Path::getBasename() const { return path.substr(slash, dot - slash); } +std::string +Path::getSuffix() const { + // Find the last slash + std::string::size_type slash = path.rfind('/'); + if (slash == std::string::npos) + slash = 0; + else + slash++; + + std::string::size_type dot = path.rfind('.'); + if (dot == std::string::npos || dot < slash) + return std::string() + else + return path.substr(dot + 1); +} + bool Path::getMagicNumber(std::string& Magic, unsigned len) const { assert(len < 1024 && "Request for magic string too long"); char* buf = (char*) alloca(1 + len); |

