From 384f7c422acca2f3658393abfc16ea57cd74caa6 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sun, 21 Feb 2016 19:22:26 -0500 Subject: Implement utimens --- src/posix_extras.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/posix_extras.cc') 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 #include #include #include @@ -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 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) { -- cgit v1.2.3