[llvm-commits] CVS: llvm/lib/System/Win32/Path.cpp

Reid Spencer reid at x10sys.com
Tue Dec 14 17:50:25 PST 2004



Changes in directory llvm/lib/System/Win32:

Path.cpp updated: 1.15 -> 1.16
---
Log message:

For PR351: http://llvm.cs.uiuc.edu/PR351 :
* Fix implementation and documentation about LLVMGCCDIR/bytecode-libs
* Add the makeUnique method, replacement for getUniqueFilename in Support.
* Add the sys::CopyFile function, replacement for CopyFile in Support.
* Move GetLLVMConfigDir() into generic code area since its generic.


---
Diffs of the changes:  (+24 -1)

Index: llvm/lib/System/Win32/Path.cpp
diff -u llvm/lib/System/Win32/Path.cpp:1.15 llvm/lib/System/Win32/Path.cpp:1.16
--- llvm/lib/System/Win32/Path.cpp:1.15	Tue Dec 14 12:42:13 2004
+++ llvm/lib/System/Win32/Path.cpp	Tue Dec 14 19:50:13 2004
@@ -158,7 +158,7 @@
   }
 #ifdef LLVMGCCDIR
   {
-    Path tmpPath(std::string(LLVMGCCDIR) + "bytecode-libs/");
+    Path tmpPath(std::string(LLVMGCCDIR) + "lib/");
     if (tmpPath.readable())
       Paths.push_back(tmpPath);
   }
@@ -584,6 +584,29 @@
   return true;
 }
 
+void 
+CopyFile(const sys::Path &Dest, const sys::Path &Src) {
+  if (!::CopyFile(Src.c_str(), Dest.c_str(), false))
+    ThrowError("Can't copy '" + Src.toString() + 
+               "' to '" + Dest.toString() + "'");
+}
+
+void 
+Path::makeUnique() {
+  if (!exists())
+    return; // File doesn't exist already, just use it!
+
+  Path dir (*this);
+  dir.elideFile();
+  std::string fname = this->getLast();
+
+  char* newName = alloca(MAX_PATH+1);
+  if (!GetTempFileName(dir.c_str(), fname.c_str(), 0, newName))
+    ThrowError("Cannot make unique filename for '" + path + "'");
+
+  path = newName;
+}
+
 }
 }
 






More information about the llvm-commits mailing list