Skip to content

Commit

Permalink
different struct names between darwin and linux
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Aug 26, 2024
1 parent 6dc01bc commit f218b73
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 27 additions & 0 deletions file/file_darwin.go
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 3 additions & 3 deletions file/file_unix.go
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down

0 comments on commit f218b73

Please sign in to comment.