summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/PathV2.inc
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
commit6e74e11c85cb75b0bad6fd39153bc4200358701d (patch)
tree05701140d83419074584978f6c0f616ff11db3eb /llvm/lib/Support/Unix/PathV2.inc
parent772caff53295309683e0badc493fcfd22beedc59 (diff)
downloadbcm5719-llvm-6e74e11c85cb75b0bad6fd39153bc4200358701d.tar.gz
bcm5719-llvm-6e74e11c85cb75b0bad6fd39153bc4200358701d.zip
Support/FileSystem: Add remove implementation.
llvm-svn: 120817
Diffstat (limited to 'llvm/lib/Support/Unix/PathV2.inc')
-rw-r--r--llvm/lib/Support/Unix/PathV2.inc14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc
index 985dde7426a..e6972f83363 100644
--- a/llvm/lib/Support/Unix/PathV2.inc
+++ b/llvm/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);
OpenPOWER on IntegriCloud