diff --git a/file/file_darwin.go b/file/file_darwin.go new file mode 100644 index 0000000..624573a --- /dev/null +++ b/file/file_darwin.go @@ -0,0 +1,27 @@ +//go:build darwin + +package file + +import ( + "os" + "syscall" + "time" + + "golang.org/x/sys/unix" +) + +func getOSFileInfo(info os.FileInfo) *FileInfo { + fi := &FileInfo{} + if s, ok := info.Sys().(*syscall.Stat_t); ok { + fi.Nlink = uint32(s.Nlink) + fi.UID = s.Uid + fi.GID = s.Gid + fi.Major = unix.Major(uint64(s.Rdev)) + fi.Minor = unix.Minor(uint64(s.Rdev)) + fi.Fileid = s.Ino + fi.Atime = time.Unix(s.Atimespec.Sec, s.Atimespec.Nsec) + fi.Ctime = time.Unix(s.Ctimespec.Sec, s.Ctimespec.Nsec) + return fi + } + return nil +} diff --git a/file/file_unix.go b/file/file_unix.go index edc86ce..220aedc 100644 --- a/file/file_unix.go +++ b/file/file_unix.go @@ -1,4 +1,4 @@ -//go:build darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris +//go:build dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris package file @@ -19,8 +19,8 @@ func getOSFileInfo(info os.FileInfo) *FileInfo { fi.Major = unix.Major(uint64(s.Rdev)) fi.Minor = unix.Minor(uint64(s.Rdev)) fi.Fileid = s.Ino - fi.Atime = time.Unix(s.Atimespec.Sec, s.Atimespec.Nsec) - fi.Ctime = time.Unix(s.Ctimespec.Sec, s.Ctimespec.Nsec) + fi.Atime = time.Unix(s.Atim.Sec, s.Atim.Nsec) + fi.Ctime = time.Unix(s.Ctim.Sec, s.Ctim.Nsec) return fi } return nil