summaryrefslogtreecommitdiff
path: root/support/lib
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-08-07 21:28:50 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-08-07 21:28:50 +0000
commit3d1b0c73319ec1d01ec927ead03a09bbc62c7aea (patch)
tree68a7f7357981bef6cf27625f62b19b2cc7096cad /support/lib
parent57d708b122d6fccaf2d5f8a4544f23ec1ad3060c (diff)
downloadllvm-3d1b0c73319ec1d01ec927ead03a09bbc62c7aea.tar.gz
llvm-3d1b0c73319ec1d01ec927ead03a09bbc62c7aea.tar.bz2
llvm-3d1b0c73319ec1d01ec927ead03a09bbc62c7aea.tar.xz
Moved removeFile() and getUniqueFilename() into FileUtilities.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support/lib')
-rw-r--r--support/lib/Support/FileUtilities.cpp35
-rw-r--r--support/lib/Support/SystemUtils.cpp37
2 files changed, 36 insertions, 36 deletions
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.
///