-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(stat): Fix architecture problems with access
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |