[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp SystemUtils.cpp

Misha Brukman brukman at cs.uiuc.edu
Thu Aug 7 16:30:03 PDT 2003


Changes in directory llvm/lib/Support:

FileUtilities.cpp updated: 1.1 -> 1.2
SystemUtils.cpp updated: 1.9 -> 1.10

---
Log message:

Moved removeFile() and getUniqueFilename() into FileUtilities.


---
Diffs of the changes:

Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.1 llvm/lib/Support/FileUtilities.cpp:1.2
--- llvm/lib/Support/FileUtilities.cpp:1.1	Fri Aug  1 16:16:14 2003
+++ llvm/lib/Support/FileUtilities.cpp	Thu Aug  7 16:28:50 2003
@@ -54,3 +54,38 @@
     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: llvm/lib/Support/SystemUtils.cpp
diff -u llvm/lib/Support/SystemUtils.cpp:1.9 llvm/lib/Support/SystemUtils.cpp:1.10
--- llvm/lib/Support/SystemUtils.cpp:1.9	Fri Aug  1 15:29:18 2003
+++ llvm/lib/Support/SystemUtils.cpp	Thu Aug  7 16:28:50 2003
@@ -5,7 +5,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "SystemUtils.h"
+#include "Support/SystemUtils.h"
 #include <algorithm>
 #include <fstream>
 #include <iostream>
@@ -16,41 +16,6 @@
 #include "Config/sys/wait.h"
 #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.





More information about the llvm-commits mailing list