diff options
| author | Ted Kremenek <kremenek@apple.com> | 2007-12-18 22:07:33 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2007-12-18 22:07:33 +0000 |
| commit | 14020706d80572504c107fcf6a8d1aaad4d0f2ff (patch) | |
| tree | 63bdecc3cd60d3501e61a8525a3841d6d5400920 | |
| parent | f70d24d2ae9e4b4e32e82b0ccb97d3b3d6ba9cbe (diff) | |
| download | bcm5719-llvm-14020706d80572504c107fcf6a8d1aaad4d0f2ff.tar.gz bcm5719-llvm-14020706d80572504c107fcf6a8d1aaad4d0f2ff.zip | |
Added "GetCurrentDirectory()" to sys::Path.
llvm-svn: 45182
| -rw-r--r-- | llvm/include/llvm/System/Path.h | 5 | ||||
| -rw-r--r-- | llvm/lib/System/Unix/Path.inc | 10 | ||||
| -rw-r--r-- | llvm/lib/System/Win32/Path.inc | 9 |
3 files changed, 24 insertions, 0 deletions
diff --git a/llvm/include/llvm/System/Path.h b/llvm/include/llvm/System/Path.h index 8ae8a006f8d..ee26b82c713 100644 --- a/llvm/include/llvm/System/Path.h +++ b/llvm/include/llvm/System/Path.h @@ -148,6 +148,11 @@ namespace sys { /// constructor must provide the same result as GetRootDirectory. /// @brief Construct a path to the current user's "home" directory static Path GetUserHomeDirectory(); + + /// Construct a path to the current directory for the current process. + /// @returns The current working directory. + /// @brief Returns the current working directory. + static Path GetCurrentDirectory(); /// Return the suffix commonly used on file names that contain a shared /// object, shared archive, or dynamic link library. Such files are diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index 9e90dda04e0..025357258dc 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/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/llvm/lib/System/Win32/Path.inc b/llvm/lib/System/Win32/Path.inc index 2484b8a744e..7d965291613 100644 --- a/llvm/lib/System/Win32/Path.inc +++ b/llvm/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. |

