mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
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
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user