1// Copyright 2009 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5// https://golang.org/src/os/stat_nacljs.go 6 7// +build js,wasm 8 9package times 10 11import ( 12 "os" 13 "syscall" 14 "time" 15) 16 17// HasChangeTime and HasBirthTime are true if and only if 18// the target OS supports them. 19const ( 20 HasChangeTime = true 21 HasBirthTime = false 22) 23 24type timespec struct { 25 atime 26 mtime 27 ctime 28 nobtime 29} 30 31func timespecToTime(sec, nsec int64) time.Time { 32 return time.Unix(sec, nsec) 33} 34 35func getTimespec(fi os.FileInfo) (t timespec) { 36 stat := fi.Sys().(*syscall.Stat_t) 37 t.atime.v = timespecToTime(stat.Atime, stat.AtimeNsec) 38 t.mtime.v = timespecToTime(stat.Mtime, stat.MtimeNsec) 39 t.ctime.v = timespecToTime(stat.Ctime, stat.CtimeNsec) 40 return t 41} 42