diff options
author | Brad Fitzpatrick <brad@danga.com> | 2010-05-19 17:48:53 -0700 |
---|---|---|
committer | Brad Fitzpatrick <brad@danga.com> | 2010-05-19 17:48:53 -0700 |
commit | af486cb23fca3b3b47a698b6bc7be637f80597a0 (patch) | |
tree | b8bb687775f9f99701316b446ce673f292eeed9b /src/pkg/os/file.go | |
parent | 94b3292622846b33dafe15d32d2b20cd2ce1fbef (diff) | |
download | golang-af486cb23fca3b3b47a698b6bc7be637f80597a0.tar.gz |
os: add Chtimes function
R=rsc, r
CC=golang-dev
http://codereview.appspot.com/1103041
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/os/file.go')
-rw-r--r-- | src/pkg/os/file.go | 16 |
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 +} |