summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Win32
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-15 08:32:45 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-15 08:32:45 +0000
commit98ce23ffb0681e34c00feeaed54ba8e4fbe686a2 (patch)
tree4caa6db433afb2077958b406035b123df33050f4 /llvm/lib/System/Win32
parent5b489416c9007f4dd09c06b0bc8c484125da6ff3 (diff)
downloadbcm5719-llvm-98ce23ffb0681e34c00feeaed54ba8e4fbe686a2.tar.gz
bcm5719-llvm-98ce23ffb0681e34c00feeaed54ba8e4fbe686a2.zip
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. llvm-svn: 18961
Diffstat (limited to 'llvm/lib/System/Win32')
-rw-r--r--llvm/lib/System/Win32/Path.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/System/Win32/Path.cpp b/llvm/lib/System/Win32/Path.cpp
index 24cfc465181..21e07c8ae13 100644
--- a/llvm/lib/System/Win32/Path.cpp
+++ b/llvm/lib/System/Win32/Path.cpp
@@ -587,8 +587,8 @@ CopyFile(const sys::Path &Dest, const sys::Path &Src) {
}
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::makeUnique() {
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 );
+}
+
}
}
OpenPOWER on IntegriCloud