Browse Source

修复 linux 获取文件访问时间的问题

Signed-off-by: 716 <[email protected]>
716 3 years ago
parent
commit
18ec8945d7
1 changed files with 5 additions and 1 deletions
  1. 5 1
      internal/pkg/get_access_time/linux.go

+ 5 - 1
internal/pkg/get_access_time/linux.go

@@ -24,5 +24,9 @@ func (d OneGetAccessTime) GetAccessTime(fileName string) (time.Time, error) {
 	}
 
 	aTime := fi.Sys().(*syscall.Stat_t).Atim
-	return time.Unix(aTime.Nanoseconds()/1e9, 0), nil
+	return timeSpecToTime(aTime), nil
+}
+
+func timeSpecToTime(ts syscall.Timespec) time.Time {
+	return time.Unix(int64(ts.Sec), int64(ts.Nsec))
 }