aboutsummaryrefslogtreecommitdiff
path: root/src/posix_extras.cc
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2016-02-21 19:22:26 -0500
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2016-02-21 20:38:02 -0500
commit384f7c422acca2f3658393abfc16ea57cd74caa6 (patch)
tree97b225ee9a78141e4c1bedb63ec0e44f9f56f34c /src/posix_extras.cc
parent05cafc5002360015a79484e6ee40c159b1c80958 (diff)
Implement utimens
Diffstat (limited to 'src/posix_extras.cc')
-rw-r--r--src/posix_extras.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/posix_extras.cc b/src/posix_extras.cc
index f8274fb..7529251 100644
--- a/src/posix_extras.cc
+++ b/src/posix_extras.cc
@@ -14,6 +14,7 @@
#include "posix_extras.h"
+#include <array>
#include <cerrno>
#include <experimental/optional>
#include <stdexcept>
@@ -110,6 +111,18 @@ void File::UnlinkAt(const char* const path) const {
}
}
+void File::UTimeNs(const char* const path, const timespec& access,
+ const timespec& modification) const {
+ if (path[0] == '/') {
+ throw std::invalid_argument("absolute path");
+ }
+
+ std::array<const timespec, 2> times{{access, modification}};
+ if (utimensat(fd_, path, times.data(), AT_SYMLINK_NOFOLLOW) == -1) {
+ throw SystemError();
+ }
+}
+
int File::Duplicate() const {
int result;
if ((result = dup(fd_)) == -1) {