diff options
Diffstat (limited to 'llvm/lib/System')
-rw-r--r-- | llvm/lib/System/Unix/Path.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/System/Win32/Path.cpp | 14 |
2 files changed, 16 insertions, 6 deletions
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, 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 ); +} + } } |