aboutsummaryrefslogtreecommitdiff
path: root/src/posix_extras.cc
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2016-02-21 20:32:29 -0500
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2016-02-21 20:38:12 -0500
commitfa0cb2cf4e0b52e57f50b2b8cc25228d481abc31 (patch)
tree9f1945429ff6ca0c4168b6c6d9c24577addfbafa /src/posix_extras.cc
parent4f9c17ee5044c68a358a92e90772eea5b3966e3c (diff)
Implement chmod
Diffstat (limited to 'src/posix_extras.cc')
-rw-r--r--src/posix_extras.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/posix_extras.cc b/src/posix_extras.cc
index 17fe275..8a63d11 100644
--- a/src/posix_extras.cc
+++ b/src/posix_extras.cc
@@ -67,6 +67,15 @@ struct stat File::Stat() const {
return result;
}
+void File::ChModAt(const char* const path, const mode_t mode) const {
+ if (path[0] == '/') {
+ throw std::invalid_argument("absolute path");
+ }
+ if (fchmodat(fd_, path, mode, 0) == -1) {
+ throw SystemError();
+ }
+}
+
struct stat File::LinkStatAt(const char* const path) const {
if (path[0] == '/') {
throw std::invalid_argument("absolute path");