Skip to content

Commit 437598d

Browse files
committed
Include atime architectural separation from steputils master
1 parent 1d5764a commit 437598d

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

fileutil/atime_darwin.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build darwin || freebsd || netbsd || openbsd
2+
3+
package fileutil
4+
5+
import (
6+
"syscall"
7+
"time"
8+
)
9+
10+
func atimeFromStat(stat *syscall.Stat_t) time.Time {
11+
return time.Unix(int64(stat.Atimespec.Sec), int64(stat.Atimespec.Nsec))
12+
}

fileutil/atime_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build linux
2+
3+
package fileutil
4+
5+
import (
6+
"syscall"
7+
"time"
8+
)
9+
10+
func atimeFromStat(stat *syscall.Stat_t) time.Time {
11+
return time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
12+
}

fileutil/copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (fm fileManager) copyTimes(srcInfo os.FileInfo, dstPath string) error {
166166
if stat, ok := srcInfo.Sys().(*syscall.Stat_t); ok {
167167
// set times (for non-symlink paths we use os.chtimes)
168168
if srcInfo.Mode()&os.ModeSymlink == 0 {
169-
atime := time.Unix(stat.Atimespec.Sec, stat.Atimespec.Nsec)
169+
atime := atimeFromStat(stat)
170170
mtime := srcInfo.ModTime()
171171
if err := fm.chtimes(dstPath, atime, mtime); err != nil {
172172
return fmt.Errorf("chtimes %s: %w", dstPath, err)

0 commit comments

Comments
 (0)