diff --git a/stat/access_date_darwin.go b/stat/access_date_darwin.go new file mode 100644 index 0000000..115c0f2 --- /dev/null +++ b/stat/access_date_darwin.go @@ -0,0 +1,19 @@ +//go:build darwin +// +build darwin + +package stat + +import ( + "os" + "syscall" + "time" +) + +func AccessDate(info os.FileInfo) (t time.Time, err error) { + stat, ok := info.Sys().(*syscall.Stat_t) + if !ok { + return t, ErrGettingStruct + } + t = time.Unix(stat.Atimespec.Sec, stat.Atimespec.Nsec) + return +} diff --git a/stat/access_date_unix.go b/stat/access_date_unix.go index 95332d1..416a4fc 100644 --- a/stat/access_date_unix.go +++ b/stat/access_date_unix.go @@ -1,5 +1,7 @@ -//go:build unix +//go:build unix && !darwin && (amd64 || arm64) // +build unix +// +build !darwin +// +build amd64 arm64 package stat diff --git a/stat/access_date_unix_386.go b/stat/access_date_unix_386.go new file mode 100644 index 0000000..4d78b9a --- /dev/null +++ b/stat/access_date_unix_386.go @@ -0,0 +1,21 @@ +//go:build unix && !darwin && (arm || 386) +// +build unix +// +build !darwin +// +build arm 386 + +package stat + +import ( + "os" + "syscall" + "time" +) + +func AccessDate(info os.FileInfo) (t time.Time, err error) { + stat, ok := info.Sys().(*syscall.Stat_t) + if !ok { + return t, ErrGettingStruct + } + t = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) + return +}