summaryrefslogtreecommitdiff
path: root/include/llvm/Support/FileUtilities.h
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-03-31 13:04:19 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-03-31 13:04:19 +0000
commitc9c08fb3a7fb5e8ea3e1477a88507704c7a70ba1 (patch)
tree09765d1b73ddfab76c21df840c3d6b9905521320 /include/llvm/Support/FileUtilities.h
parentdc5198bac7e3f9b61617c8c46a1c28a84daa9325 (diff)
downloadllvm-c9c08fb3a7fb5e8ea3e1477a88507704c7a70ba1.tar.gz
llvm-c9c08fb3a7fb5e8ea3e1477a88507704c7a70ba1.tar.bz2
llvm-c9c08fb3a7fb5e8ea3e1477a88507704c7a70ba1.tar.xz
Switch FileRemover from PathV1 to V2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128630 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/FileUtilities.h')
-rw-r--r--include/llvm/Support/FileUtilities.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/include/llvm/Support/FileUtilities.h b/include/llvm/Support/FileUtilities.h
index 748ce7cea7..aab4539088 100644
--- a/include/llvm/Support/FileUtilities.h
+++ b/include/llvm/Support/FileUtilities.h
@@ -15,6 +15,7 @@
#ifndef LLVM_SUPPORT_FILEUTILITIES_H
#define LLVM_SUPPORT_FILEUTILITIES_H
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
namespace llvm {
@@ -37,29 +38,36 @@ namespace llvm {
/// specified (if deleteIt is true).
///
class FileRemover {
- sys::Path Filename;
+ SmallString<128> Filename;
bool DeleteIt;
public:
FileRemover() : DeleteIt(false) {}
- explicit FileRemover(const sys::Path &filename, bool deleteIt = true)
- : Filename(filename), DeleteIt(deleteIt) {}
+ explicit FileRemover(const Twine& filename, bool deleteIt = true)
+ : DeleteIt(deleteIt) {
+ filename.toVector(Filename);
+ }
~FileRemover() {
if (DeleteIt) {
// Ignore problems deleting the file.
- Filename.eraseFromDisk();
+ bool existed;
+ sys::fs::remove(Filename.str(), existed);
}
}
/// setFile - Give ownership of the file to the FileRemover so it will
/// be removed when the object is destroyed. If the FileRemover already
/// had ownership of a file, remove it first.
- void setFile(const sys::Path &filename, bool deleteIt = true) {
- if (DeleteIt)
- Filename.eraseFromDisk();
+ void setFile(const Twine& filename, bool deleteIt = true) {
+ if (DeleteIt) {
+ // Ignore problems deleting the file.
+ bool existed;
+ sys::fs::remove(Filename.str(), existed);
+ }
- Filename = filename;
+ Filename.clear();
+ filename.toVector(Filename);
DeleteIt = deleteIt;
}