mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 18:34:41 +01:00
.. | ||
.travis.sh | ||
.travis.yml | ||
ctime_windows.go | ||
js.cover.dockerfile | ||
js.cover.sh | ||
LICENSE | ||
README.md | ||
times_darwin.go | ||
times_dragonfly.go | ||
times_freebsd.go | ||
times_js.go | ||
times_linux.go | ||
times_nacl.go | ||
times_netbsd.go | ||
times_openbsd.go | ||
times_plan9.go | ||
times_solaris.go | ||
times_windows.go | ||
times.go | ||
use_generic_stat.go |
times
Usage
File Times for #golang
Go has a hidden time functions for most platforms, this repo makes them accessible.
package main
import (
"log"
"gopkg.in/djherbis/times.v1"
)
func main() {
t, err := times.Stat("myfile")
if err != nil {
log.Fatal(err.Error())
}
log.Println(t.AccessTime())
log.Println(t.ModTime())
if t.HasChangeTime() {
log.Println(t.ChangeTime())
}
if t.HasBirthTime() {
log.Println(t.BirthTime())
}
}
Supported Times
windows | linux | solaris | dragonfly | nacl | freebsd | darwin | netbsd | openbsd | plan9 | js | |
---|---|---|---|---|---|---|---|---|---|---|---|
atime | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
mtime | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
ctime | ✓* | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
btime | ✓ | ✓ | ✓ | ✓ |
- Windows XP does not have ChangeTime so HasChangeTime = false, however Vista onward does have ChangeTime so Timespec.HasChangeTime() will only return false on those platforms when the syscall used to obtain them fails.
- Also note, Get(FileInfo) will now only return values available in FileInfo.Sys(), this means Stat() is required to get ChangeTime on Windows
Installation
go get gopkg.in/djherbis/times.v1