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

Reid Spencer reid at x10sys.com
Wed Dec 15 00:32:56 PST 2004



Changes in directory llvm/lib/System/Win32:

Path.cpp updated: 1.17 -> 1.18
---
Log message:

Fix a file overwrite bug in llvm-ar introduced by changes to 
createTemporaryFile semantics where it doesn't create a fully unique name
if the basename doesn't exist. This functionality is now optionally
provided by the boolean reuse_current parameter to createTemporaryFile and
makeUnique. The default values differ because of the way these functions
are used in LLVM.


---
Diffs of the changes:  (+12 -2)

Index: llvm/lib/System/Win32/Path.cpp
diff -u llvm/lib/System/Win32/Path.cpp:1.17 llvm/lib/System/Win32/Path.cpp:1.18
--- llvm/lib/System/Win32/Path.cpp:1.17	Tue Dec 14 22:08:15 2004
+++ llvm/lib/System/Win32/Path.cpp	Wed Dec 15 02:32:45 2004
@@ -587,8 +587,8 @@
 }
 
 void 
-Path::makeUnique() {
-  if (!exists())
+Path::makeUnique( bool reuse_current ) {
+  if (reuse_current && !exists())
     return; // File doesn't exist already, just use it!
 
   Path dir (*this);
@@ -602,6 +602,16 @@
   path = newName;
 }
 
+bool
+Path::createTemporaryFile(bool reuse_current) {
+  // Make sure we're dealing with a file
+  if (!isFile()) 
+    return false;
+
+  // Make this into a unique file name
+  makeUnique( reuse_current );
+}
+
 }
 }
 






More information about the llvm-commits mailing list