From 79200788df8d946eae6973709b998a7f3a4cb754 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 18 Dec 2007 22:07:33 +0000 Subject: Added "GetCurrentDirectory()" to sys::Path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45182 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/System/Unix/Path.inc | 10 ++++++++++ lib/System/Win32/Path.inc | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'lib/System') diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 9e90dda..0253572 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -250,6 +250,16 @@ Path::GetUserHomeDirectory() { return GetRootDirectory(); } +Path +Path::GetCurrentDirectory() { + char pathname[MAXPATHLEN]; + if (!getcwd(pathname,MAXPATHLEN)) { + assert (false && "Could not query current working directory."); + return Path(""); + } + + return Path(pathname); +} std::string Path::getBasename() const { diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index 2484b8a..7d96529 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -222,6 +222,15 @@ Path::GetUserHomeDirectory() { } return GetRootDirectory(); } + +Path +Path::GetCurrentDirectory() { + char pathname[MAX_PATH]; + GetCurrentDirectory(pathname,MAX_PATH); + return Path(pathname); +} + + // FIXME: the above set of functions don't map to Windows very well. -- cgit v1.1