From 6e74e11c85cb75b0bad6fd39153bc4200358701d Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Fri, 3 Dec 2010 17:53:43 +0000 Subject: Support/FileSystem: Add remove implementation. llvm-svn: 120817 --- llvm/lib/Support/Unix/PathV2.inc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'llvm/lib/Support/Unix/PathV2.inc') 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); -- cgit v1.2.3