summaryrefslogtreecommitdiff
path: root/src/pkg/os/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/file.go')
-rw-r--r--src/pkg/os/file.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go
index ccecf67ed..3196406d6 100644
--- a/src/pkg/os/file.go
+++ b/src/pkg/os/file.go
@@ -407,3 +407,19 @@ func (f *File) Truncate(size int64) Error {
}
return nil
}
+
+// Chtimes changes the access and modification times of the named
+// file, similar to the Unix utime() or utimes() functions.
+//
+// The argument times are in nanoseconds, although the underlying
+// filesystem may truncate or round the values to a more
+// coarse time unit.
+func Chtimes(name string, atime_ns int64, mtime_ns int64) Error {
+ var utimes [2]syscall.Timeval
+ utimes[0] = syscall.NsecToTimeval(atime_ns)
+ utimes[1] = syscall.NsecToTimeval(mtime_ns)
+ if e := syscall.Utimes(name, &utimes); e != 0 {
+ return &PathError{"chtimes", name, Errno(e)}
+ }
+ return nil
+}