LEFT | RIGHT |
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 // The os package provides a platform-independent interface to operating | 5 // The os package provides a platform-independent interface to operating |
6 // system functionality. The design is Unix-like. | 6 // system functionality. The design is Unix-like. |
7 package os | 7 package os |
8 | 8 |
9 import ( | 9 import ( |
10 "runtime" | 10 "runtime" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 // Truncate changes the size of the file. | 402 // Truncate changes the size of the file. |
403 // It does not change the I/O offset. | 403 // It does not change the I/O offset. |
404 func (f *File) Truncate(size int64) Error { | 404 func (f *File) Truncate(size int64) Error { |
405 if e := syscall.Ftruncate(f.fd, size); e != 0 { | 405 if e := syscall.Ftruncate(f.fd, size); e != 0 { |
406 return &PathError{"truncate", f.name, Errno(e)} | 406 return &PathError{"truncate", f.name, Errno(e)} |
407 } | 407 } |
408 return nil | 408 return nil |
409 } | 409 } |
410 | 410 |
411 // Utime changes the access and modification times of the named file. | 411 // Chtimes changes the access and modification times of the named |
412 func Utime(name string, atime_ns int64, mtime_ns int64) Error { | 412 // file, similar to the Unix utime() or utimes() functions. |
| 413 // |
| 414 // The argument times are in nanoseconds, although the underlying |
| 415 // filesystem may truncate or round the values to a more |
| 416 // coarse time unit. |
| 417 func Chtimes(name string, atime_ns int64, mtime_ns int64) Error { |
413 var utimes [2]syscall.Timeval | 418 var utimes [2]syscall.Timeval |
414 utimes[0] = syscall.NsecToTimeval(atime_ns) | 419 utimes[0] = syscall.NsecToTimeval(atime_ns) |
415 utimes[1] = syscall.NsecToTimeval(mtime_ns) | 420 utimes[1] = syscall.NsecToTimeval(mtime_ns) |
416 if e := syscall.Utimes(name, &utimes); e != 0 { | 421 if e := syscall.Utimes(name, &utimes); e != 0 { |
417 return &PathError{"utime", name, Errno(e)} | 422 » » return &PathError{"chtimes", name, Errno(e)} |
418 } | 423 » } |
419 return nil | 424 » return nil |
420 } | 425 } |
LEFT | RIGHT |