Skip to content

Commit

Permalink
fix(stat): Fix architecture problems with access
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom5521 committed Jun 25, 2024
1 parent d0e3153 commit 59d0e15
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
19 changes: 19 additions & 0 deletions stat/access_date_darwin.go
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 3 additions & 1 deletion stat/access_date_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//go:build unix
//go:build unix && !darwin && (amd64 || arm64)
// +build unix
// +build !darwin
// +build amd64 arm64

package stat

Expand Down
21 changes: 21 additions & 0 deletions stat/access_date_unix_386.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 59d0e15

Please sign in to comment.