[llvm-commits] CVS: llvm/include/Support/FileUtilities.h
Chris Lattner
lattner at cs.uiuc.edu
Wed Feb 18 11:59:01 PST 2004
Changes in directory llvm/include/Support:
FileUtilities.h updated: 1.14 -> 1.15
---
Log message:
Move a helper class out of bugpoint to here.
---
Diffs of the changes: (+20 -0)
Index: llvm/include/Support/FileUtilities.h
diff -u llvm/include/Support/FileUtilities.h:1.14 llvm/include/Support/FileUtilities.h:1.15
--- llvm/include/Support/FileUtilities.h:1.14 Wed Dec 31 00:16:02 2003
+++ llvm/include/Support/FileUtilities.h Wed Feb 18 11:16:17 2004
@@ -131,6 +131,26 @@
return Ret;
}
};
+
+ /// FileRemover - This class is a simple object meant to be stack allocated.
+ /// If an exception is thrown from a region, the object removes the filename
+ /// specified (if deleteIt is true).
+ ///
+ class FileRemover {
+ bool DeleteIt;
+ std::string Filename;
+ public:
+ FileRemover(bool deleteIt, const std::string &filename)
+ : DeleteIt(deleteIt), Filename(filename) {}
+
+ ~FileRemover() {
+ if (DeleteIt) removeFile(Filename);
+ }
+
+ /// releaseFile - Take ownership of the file away from the FileRemover so it
+ /// will not be removed when the object is destroyed.
+ void releaseFile() { DeleteIt = false; }
+ };
} // End llvm namespace
#endif
More information about the llvm-commits
mailing list