From af486cb23fca3b3b47a698b6bc7be637f80597a0 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 19 May 2010 17:48:53 -0700 Subject: os: add Chtimes function R=rsc, r CC=golang-dev http://codereview.appspot.com/1103041 Committer: Russ Cox --- src/pkg/os/file.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/pkg/os/file.go') 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 +} -- cgit v1.2.3