aboutsummaryrefslogtreecommitdiff
path: root/lib/System/Win32/Path.cpp
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
commit07f9f4e2a41ed5b431b69165890ad9bc6f44edde (patch)
tree4333a3122cc14ab874a0ed3af6548b3b14183a05 /lib/System/Win32/Path.cpp
parent8378294c687c67540d96734b9b82f56486e88bfa (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32/Path.cpp')
-rw-r--r--lib/System/Win32/Path.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/System/Win32/Path.cpp b/lib/System/Win32/Path.cpp
index 24cfc46518..21e07c8ae1 100644
--- a/lib/System/Win32/Path.cpp
+++ b/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 );
+}
+
}
}