Moved removeFile() and getUniqueFilename() into FileUtilities.
authorMisha Brukman <brukman+llvm@gmail.com>
Thu, 7 Aug 2003 21:28:50 +0000 (21:28 +0000)
committerMisha Brukman <brukman+llvm@gmail.com>
Thu, 7 Aug 2003 21:28:50 +0000 (21:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7691 91177308-0d34-0410-b5e6-96231b3b80d8

include/Support/FileUtilities.h
include/Support/SystemUtils.h
include/llvm/Support/FileUtilities.h
include/llvm/Support/SystemUtils.h
lib/Support/FileUtilities.cpp
lib/Support/SystemUtils.cpp
support/lib/Support/FileUtilities.cpp
support/lib/Support/SystemUtils.cpp

index 8d310203e734f9202acb45f1eeb95f746b90c0c4..2c8eba394962fba2893cef86e8bd0ed8d1aa0241 100644 (file)
@@ -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
index 2d5dadc14cec838c90e11b7de0007043e8019fa6..7321cb54fc169a59d87565727cccb53e5b516269 100644 (file)
@@ -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
index 8d310203e734f9202acb45f1eeb95f746b90c0c4..2c8eba394962fba2893cef86e8bd0ed8d1aa0241 100644 (file)
@@ -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
index 2d5dadc14cec838c90e11b7de0007043e8019fa6..7321cb54fc169a59d87565727cccb53e5b516269 100644 (file)
@@ -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
index 35bdf1e9a4de7edb248291f73d82a42501b50c3f..9f9ef30686839e1c659b6a3277001af84b2afa8c 100644 (file)
@@ -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;
+}
index ec0bcb3296e0c5937de442226577b9f3c719fd57..b23888e2b05a71a2b05af4cb7d45fbb4d2d30792 100644 (file)
@@ -5,7 +5,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "SystemUtils.h"
+#include "Support/SystemUtils.h"
 #include <algorithm>
 #include <fstream>
 #include <iostream>
 #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.
 ///
index 35bdf1e9a4de7edb248291f73d82a42501b50c3f..9f9ef30686839e1c659b6a3277001af84b2afa8c 100644 (file)
@@ -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;
+}
index ec0bcb3296e0c5937de442226577b9f3c719fd57..b23888e2b05a71a2b05af4cb7d45fbb4d2d30792 100644 (file)
@@ -5,7 +5,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "SystemUtils.h"
+#include "Support/SystemUtils.h"
 #include <algorithm>
 #include <fstream>
 #include <iostream>
 #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.
 ///