2017-11-10 18:16:38 +08:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2019-02-09 20:50:35 +08:00
|
|
|
// https://golang.org/src/os/stat_nacljs.go
|
2017-11-10 18:16:38 +08:00
|
|
|
|
|
|
|
package times
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"syscall"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// HasChangeTime and HasBirthTime are true if and only if
|
|
|
|
// the target OS supports them.
|
|
|
|
const (
|
|
|
|
HasChangeTime = true
|
|
|
|
HasBirthTime = false
|
|
|
|
)
|
|
|
|
|
|
|
|
type timespec struct {
|
|
|
|
atime
|
|
|
|
mtime
|
|
|
|
ctime
|
|
|
|
nobtime
|
|
|
|
}
|
|
|
|
|
|
|
|
func timespecToTime(sec, nsec int64) time.Time {
|
|
|
|
return time.Unix(sec, nsec)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getTimespec(fi os.FileInfo) (t timespec) {
|
|
|
|
stat := fi.Sys().(*syscall.Stat_t)
|
|
|
|
t.atime.v = timespecToTime(stat.Atime, stat.AtimeNsec)
|
|
|
|
t.mtime.v = timespecToTime(stat.Mtime, stat.MtimeNsec)
|
|
|
|
t.ctime.v = timespecToTime(stat.Ctime, stat.CtimeNsec)
|
|
|
|
return t
|
|
|
|
}
|