From 98ce23ffb0681e34c00feeaed54ba8e4fbe686a2 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 15 Dec 2004 08:32:45 +0000 Subject: 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 --- llvm/lib/System/Unix/Path.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/System/Unix/Path.cpp') diff --git a/llvm/lib/System/Unix/Path.cpp b/llvm/lib/System/Unix/Path.cpp index d4bf0260c56..84c2d2d23d5 100644 --- a/llvm/lib/System/Unix/Path.cpp +++ b/llvm/lib/System/Unix/Path.cpp @@ -481,13 +481,13 @@ Path::createFile() { } bool -Path::createTemporaryFile() { +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(); + makeUnique( reuse_current ); // create the file int outFile = ::open(path.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666); @@ -600,8 +600,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! // Append an XXXXXX pattern to the end of the file for use with mkstemp, -- cgit v1.2.3