aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Unix
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 17:53:43 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 17:53:43 +0000
commit106aa731bf86c632a6362497742c6df7bce61a07 (patch)
tree8bd87c4f59df5d60f9f498a68b66d6a5e0fd63a4 /lib/Support/Unix
parent998b4709cba317f78127544cf5ae80121b6ad039 (diff)
Support/FileSystem: Add remove implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r--lib/Support/Unix/PathV2.inc14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc
index 985dde7426..e6972f8336 100644
--- a/lib/Support/Unix/PathV2.inc
+++ b/lib/Support/Unix/PathV2.inc
@@ -186,6 +186,20 @@ error_code create_symlink(const Twine &to, const Twine &from) {
return make_error_code(errc::success);
}
+error_code remove(const Twine &path, bool &existed) {
+ SmallString<128> path_storage;
+ StringRef p = path.toNullTerminatedStringRef(path_storage);
+
+ if (::remove(p.begin()) == -1) {
+ if (errno != ENOENT)
+ return error_code(errno, system_category());
+ existed = false;
+ } else
+ existed = true;
+
+ return make_error_code(errc::success);
+}
+
error_code exists(const Twine &path, bool &result) {
SmallString<128> path_storage;
StringRef p = path.toNullTerminatedStringRef(path_storage);