diff options
-rw-r--r-- | include/Support/FileUtilities.h | 10 | ||||
-rw-r--r-- | include/Support/SystemUtils.h | 10 | ||||
-rw-r--r-- | include/llvm/Support/FileUtilities.h | 10 | ||||
-rw-r--r-- | include/llvm/Support/SystemUtils.h | 10 | ||||
-rw-r--r-- | lib/Support/FileUtilities.cpp | 35 | ||||
-rw-r--r-- | lib/Support/SystemUtils.cpp | 37 | ||||
-rw-r--r-- | support/lib/Support/FileUtilities.cpp | 35 | ||||
-rw-r--r-- | support/lib/Support/SystemUtils.cpp | 37 |
8 files changed, 92 insertions, 92 deletions
diff --git a/include/Support/FileUtilities.h b/include/Support/FileUtilities.h index 8d310203e7..2c8eba3949 100644 --- a/include/Support/FileUtilities.h +++ b/include/Support/FileUtilities.h @@ -26,4 +26,14 @@ bool DiffFiles(const std::string &FileA, const std::string &FileB, /// void MoveFileOverIfUpdated(const std::string &New, const std::string &Old); +/// removeFile - Delete the specified file +/// +void removeFile(const std::string &Filename); + +/// getUniqueFilename - Return a filename with the specified prefix. If the +/// file does not exist yet, return it, otherwise add a suffix to make it +/// unique. +/// +std::string getUniqueFilename(const std::string &FilenameBase); + #endif diff --git a/include/Support/SystemUtils.h b/include/Support/SystemUtils.h index 2d5dadc14c..7321cb54fc 100644 --- a/include/Support/SystemUtils.h +++ b/include/Support/SystemUtils.h @@ -22,16 +22,6 @@ bool isExecutableFile(const std::string &ExeFileName); std::string FindExecutable(const std::string &ExeName, const std::string &BugPointPath); -/// removeFile - Delete the specified file -/// -void removeFile(const std::string &Filename); - -/// getUniqueFilename - Return a filename with the specified prefix. If the -/// file does not exist yet, return it, otherwise add a suffix to make it -/// unique. -/// -std::string getUniqueFilename(const std::string &FilenameBase); - /// RunProgramWithTimeout - This function executes the specified program, with /// the specified null-terminated argument array, with the stdin/out/err fd's /// redirected, with a timeout specified on the commandline. This terminates diff --git a/include/llvm/Support/FileUtilities.h b/include/llvm/Support/FileUtilities.h index 8d310203e7..2c8eba3949 100644 --- a/include/llvm/Support/FileUtilities.h +++ b/include/llvm/Support/FileUtilities.h @@ -26,4 +26,14 @@ bool DiffFiles(const std::string &FileA, const std::string &FileB, /// void MoveFileOverIfUpdated(const std::string &New, const std::string &Old); +/// removeFile - Delete the specified file +/// +void removeFile(const std::string &Filename); + +/// getUniqueFilename - Return a filename with the specified prefix. If the +/// file does not exist yet, return it, otherwise add a suffix to make it +/// unique. +/// +std::string getUniqueFilename(const std::string &FilenameBase); + #endif diff --git a/include/llvm/Support/SystemUtils.h b/include/llvm/Support/SystemUtils.h index 2d5dadc14c..7321cb54fc 100644 --- a/include/llvm/Support/SystemUtils.h +++ b/include/llvm/Support/SystemUtils.h @@ -22,16 +22,6 @@ bool isExecutableFile(const std::string &ExeFileName); std::string FindExecutable(const std::string &ExeName, const std::string &BugPointPath); -/// removeFile - Delete the specified file -/// -void removeFile(const std::string &Filename); - -/// getUniqueFilename - Return a filename with the specified prefix. If the -/// file does not exist yet, return it, otherwise add a suffix to make it -/// unique. -/// -std::string getUniqueFilename(const std::string &FilenameBase); - /// RunProgramWithTimeout - This function executes the specified program, with /// the specified null-terminated argument array, with the stdin/out/err fd's /// redirected, with a timeout specified on the commandline. This terminates diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 35bdf1e9a4..9f9ef30686 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -54,3 +54,38 @@ void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { std::remove(New.c_str()); } } + +/// removeFile - Delete the specified file +/// +void removeFile(const std::string &Filename) { + std::remove(Filename.c_str()); +} + +/// getUniqueFilename - Return a filename with the specified prefix. If the +/// file does not exist yet, return it, otherwise add a suffix to make it +/// unique. +/// +std::string getUniqueFilename(const std::string &FilenameBase) { + if (!std::ifstream(FilenameBase.c_str())) + return FilenameBase; // Couldn't open the file? Use it! + + // Create a pattern for mkstemp... + char *FNBuffer = new char[FilenameBase.size()+8]; + strcpy(FNBuffer, FilenameBase.c_str()); + strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX"); + + // Agree on a temporary file name to use.... + int TempFD; + if ((TempFD = mkstemp(FNBuffer)) == -1) { + std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current " + << " directory!\n"; + exit(1); + } + + // We don't need to hold the temp file descriptor... we will trust that noone + // will overwrite/delete the file while we are working on it... + close(TempFD); + std::string Result(FNBuffer); + delete[] FNBuffer; + return Result; +} diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index ec0bcb3296..b23888e2b0 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -5,7 +5,7 @@ // //===----------------------------------------------------------------------===// -#include "SystemUtils.h" +#include "Support/SystemUtils.h" #include <algorithm> #include <fstream> #include <iostream> @@ -17,41 +17,6 @@ #include "Config/unistd.h" #include "Config/errno.h" -/// removeFile - Delete the specified file -/// -void removeFile(const std::string &Filename) { - std::remove(Filename.c_str()); -} - -/// getUniqueFilename - Return a filename with the specified prefix. If the -/// file does not exist yet, return it, otherwise add a suffix to make it -/// unique. -/// -std::string getUniqueFilename(const std::string &FilenameBase) { - if (!std::ifstream(FilenameBase.c_str())) - return FilenameBase; // Couldn't open the file? Use it! - - // Create a pattern for mkstemp... - char *FNBuffer = new char[FilenameBase.size()+8]; - strcpy(FNBuffer, FilenameBase.c_str()); - strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX"); - - // Agree on a temporary file name to use.... - int TempFD; - if ((TempFD = mkstemp(FNBuffer)) == -1) { - std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current " - << " directory!\n"; - exit(1); - } - - // We don't need to hold the temp file descriptor... we will trust that noone - // will overwrite/delete the file while we are working on it... - close(TempFD); - std::string Result(FNBuffer); - delete[] FNBuffer; - return Result; -} - /// isExecutableFile - This function returns true if the filename specified /// exists and is executable. /// diff --git a/support/lib/Support/FileUtilities.cpp b/support/lib/Support/FileUtilities.cpp index 35bdf1e9a4..9f9ef30686 100644 --- a/support/lib/Support/FileUtilities.cpp +++ b/support/lib/Support/FileUtilities.cpp @@ -54,3 +54,38 @@ void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { std::remove(New.c_str()); } } + +/// removeFile - Delete the specified file +/// +void removeFile(const std::string &Filename) { + std::remove(Filename.c_str()); +} + +/// getUniqueFilename - Return a filename with the specified prefix. If the +/// file does not exist yet, return it, otherwise add a suffix to make it +/// unique. +/// +std::string getUniqueFilename(const std::string &FilenameBase) { + if (!std::ifstream(FilenameBase.c_str())) + return FilenameBase; // Couldn't open the file? Use it! + + // Create a pattern for mkstemp... + char *FNBuffer = new char[FilenameBase.size()+8]; + strcpy(FNBuffer, FilenameBase.c_str()); + strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX"); + + // Agree on a temporary file name to use.... + int TempFD; + if ((TempFD = mkstemp(FNBuffer)) == -1) { + std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current " + << " directory!\n"; + exit(1); + } + + // We don't need to hold the temp file descriptor... we will trust that noone + // will overwrite/delete the file while we are working on it... + close(TempFD); + std::string Result(FNBuffer); + delete[] FNBuffer; + return Result; +} diff --git a/support/lib/Support/SystemUtils.cpp b/support/lib/Support/SystemUtils.cpp index ec0bcb3296..b23888e2b0 100644 --- a/support/lib/Support/SystemUtils.cpp +++ b/support/lib/Support/SystemUtils.cpp @@ -5,7 +5,7 @@ // //===----------------------------------------------------------------------===// -#include "SystemUtils.h" +#include "Support/SystemUtils.h" #include <algorithm> #include <fstream> #include <iostream> @@ -17,41 +17,6 @@ #include "Config/unistd.h" #include "Config/errno.h" -/// removeFile - Delete the specified file -/// -void removeFile(const std::string &Filename) { - std::remove(Filename.c_str()); -} - -/// getUniqueFilename - Return a filename with the specified prefix. If the -/// file does not exist yet, return it, otherwise add a suffix to make it -/// unique. -/// -std::string getUniqueFilename(const std::string &FilenameBase) { - if (!std::ifstream(FilenameBase.c_str())) - return FilenameBase; // Couldn't open the file? Use it! - - // Create a pattern for mkstemp... - char *FNBuffer = new char[FilenameBase.size()+8]; - strcpy(FNBuffer, FilenameBase.c_str()); - strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX"); - - // Agree on a temporary file name to use.... - int TempFD; - if ((TempFD = mkstemp(FNBuffer)) == -1) { - std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current " - << " directory!\n"; - exit(1); - } - - // We don't need to hold the temp file descriptor... we will trust that noone - // will overwrite/delete the file while we are working on it... - close(TempFD); - std::string Result(FNBuffer); - delete[] FNBuffer; - return Result; -} - /// isExecutableFile - This function returns true if the filename specified /// exists and is executable. /// |