From c042bf1db5f6aedd4a677950f9322675cca46d66 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 7 Apr 2008 21:53:57 +0000 Subject: Added method Path::getDirname(). llvm-svn: 49352 --- llvm/lib/System/Unix/Path.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/System/Unix') diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index c3d06a3fa1d..fe2e3c67778 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -277,16 +277,18 @@ Path Path::GetMainExecutable(const char *argv0, void *MainAddr) { } +std::string Path::getDirname() const { return getDirnameCharSep('/'); } + std::string Path::getBasename() const { // Find the last slash - size_t slash = path.rfind('/'); + std::string::size_type slash = path.rfind('/'); if (slash == std::string::npos) slash = 0; else slash++; - size_t dot = path.rfind('.'); + std::string::size_type dot = path.rfind('.'); if (dot == std::string::npos || dot < slash) return path.substr(slash); else -- cgit v1.2.3