[llvm-commits] [llvm] r45182 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Unix/Path.inc lib/System/Win32/Path.inc

Ted Kremenek kremenek at apple.com
Tue Dec 18 14:07:34 PST 2007


Author: kremenek
Date: Tue Dec 18 16:07:33 2007
New Revision: 45182

URL: http://llvm.org/viewvc/llvm-project?rev=45182&view=rev
Log:
Added "GetCurrentDirectory()" to sys::Path.

Modified:
    llvm/trunk/include/llvm/System/Path.h
    llvm/trunk/lib/System/Unix/Path.inc
    llvm/trunk/lib/System/Win32/Path.inc

Modified: llvm/trunk/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=45182&r1=45181&r2=45182&view=diff

==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Tue Dec 18 16:07:33 2007
@@ -148,6 +148,11 @@
       /// 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

Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=45182&r1=45181&r2=45182&view=diff

==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Tue Dec 18 16:07:33 2007
@@ -250,6 +250,16 @@
   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 {

Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=45182&r1=45181&r2=45182&view=diff

==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Tue Dec 18 16:07:33 2007
@@ -222,6 +222,15 @@
   }
   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.
 
 





More information about the llvm-commits mailing list