From f4b0c2e93a2f45b548465dba84b257bcb3b41446 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 20 Feb 2016 15:22:17 -0500 Subject: Implement unlink --- src/posix_extras.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/posix_extras.cc') diff --git a/src/posix_extras.cc b/src/posix_extras.cc index 4093cc0..6844785 100644 --- a/src/posix_extras.cc +++ b/src/posix_extras.cc @@ -102,6 +102,16 @@ File File::OpenAt(const char* const path, const int flags, return result; } +void File::UnlinkAt(const char* const path) const { + if (path[0] == '/') { + throw std::invalid_argument("absolute path"); + } + + if (unlinkat(fd_, path, 0) == -1) { + throw SystemError(); + } +} + int File::Duplicate() const { int result; if ((result = dup(fd_)) == -1) { -- cgit v1.2.3