aboutsummaryrefslogtreecommitdiff
path: root/src/posix_extras.cc
diff options
context:
space:
mode:
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) {