summaryrefslogtreecommitdiff
path: root/include/llvm/Support/FileUtilities.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-18 17:16:17 +0000
committerChris Lattner <sabre@nondot.org>2004-02-18 17:16:17 +0000
commitf1e3285f3a45f21d237809a8da29558981282b56 (patch)
treecaae02d999983630956f390a37b4b6a308b0ef72 /include/llvm/Support/FileUtilities.h
parenta972dadb2062ee6b0ef6f93ebf25b137b01beda5 (diff)
downloadllvm-f1e3285f3a45f21d237809a8da29558981282b56.tar.gz
llvm-f1e3285f3a45f21d237809a8da29558981282b56.tar.bz2
llvm-f1e3285f3a45f21d237809a8da29558981282b56.tar.xz
Move a helper class out of bugpoint to here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11582 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/FileUtilities.h')
-rw-r--r--include/llvm/Support/FileUtilities.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/llvm/Support/FileUtilities.h b/include/llvm/Support/FileUtilities.h
index 3bc3aa8504..7ccb694349 100644
--- a/include/llvm/Support/FileUtilities.h
+++ b/include/llvm/Support/FileUtilities.h
@@ -131,6 +131,26 @@ public:
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