LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build darwin freebsd linux netbsd openbsd windows | 5 // +build darwin freebsd linux netbsd openbsd windows |
6 | 6 |
7 package os | 7 package os |
8 | 8 |
9 import ( | 9 import ( |
10 "syscall" | 10 "syscall" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return nil | 146 return nil |
147 } | 147 } |
148 | 148 |
149 // Chtimes changes the access and modification times of the named | 149 // Chtimes changes the access and modification times of the named |
150 // file, similar to the Unix utime() or utimes() functions. | 150 // file, similar to the Unix utime() or utimes() functions. |
151 // | 151 // |
152 // The underlying filesystem may truncate or round the values to a | 152 // The underlying filesystem may truncate or round the values to a |
153 // less precise time unit. | 153 // less precise time unit. |
154 // If there is an error, it will be of type *PathError. | 154 // If there is an error, it will be of type *PathError. |
155 func Chtimes(name string, atime time.Time, mtime time.Time) error { | 155 func Chtimes(name string, atime time.Time, mtime time.Time) error { |
156 » var utimes [2]syscall.Timeval | 156 » var utimes [2]syscall.Timespec |
157 » atime_ns := atime.Unix()*1e9 + int64(atime.Nanosecond()) | 157 » utimes[0] = syscall.NsecToTimespec(atime.UnixNano()) |
158 » mtime_ns := mtime.Unix()*1e9 + int64(mtime.Nanosecond()) | 158 » utimes[1] = syscall.NsecToTimespec(mtime.UnixNano()) |
159 » utimes[0] = syscall.NsecToTimeval(atime_ns) | 159 » if e := syscall.UtimesNano(name, utimes[0:]); e != nil { |
160 » utimes[1] = syscall.NsecToTimeval(mtime_ns) | |
161 » if e := syscall.Utimes(name, utimes[0:]); e != nil { | |
162 return &PathError{"chtimes", name, e} | 160 return &PathError{"chtimes", name, e} |
163 } | 161 } |
164 return nil | 162 return nil |
165 } | 163 } |
LEFT | RIGHT |