diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2016-02-20 15:22:17 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2016-02-21 20:38:01 -0500 |
commit | f4b0c2e93a2f45b548465dba84b257bcb3b41446 (patch) | |
tree | b74a6959532ca4ad21c75bd85c348293cfe46e50 /src/posix_extras.cc | |
parent | 60cbb719e7e9b14d4966efcead89bca4fc022c8e (diff) |
Implement unlink
Diffstat (limited to 'src/posix_extras.cc')
-rw-r--r-- | src/posix_extras.cc | 10 |
1 files changed, 10 insertions, 0 deletions
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) { |