stat_bsd.go 677 B

12345678910111213141516171819202122232425262728
  1. // +build darwin freebsd
  2. package fs
  3. import (
  4. "syscall"
  5. "time"
  6. )
  7. // StatAtime returns the access time from a stat struct
  8. func StatAtime(st *syscall.Stat_t) syscall.Timespec {
  9. return st.Atimespec
  10. }
  11. // StatCtime returns the created time from a stat struct
  12. func StatCtime(st *syscall.Stat_t) syscall.Timespec {
  13. return st.Ctimespec
  14. }
  15. // StatMtime returns the modified time from a stat struct
  16. func StatMtime(st *syscall.Stat_t) syscall.Timespec {
  17. return st.Mtimespec
  18. }
  19. // StatATimeAsTime returns the access time as a time.Time
  20. func StatATimeAsTime(st *syscall.Stat_t) time.Time {
  21. return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) // nolint: unconvert
  22. }