//go:build darwin

package host_files

import (
	"os"
	"syscall"
	"time"
)

// fileTimes returns mtime and atime for the given FileInfo on Darwin.
// BSD syscall.Stat_t names the atime field Atimespec (versus Atim on
// Linux). The build-tagged variants of this function keep the handler
// in handlers.go portable across the two OSes.
func fileTimes(fi os.FileInfo) (time.Time, time.Time) {
	mtime := fi.ModTime().UTC()
	atime := mtime
	if st, ok := fi.Sys().(*syscall.Stat_t); ok {
		atime = time.Unix(st.Atimespec.Sec, st.Atimespec.Nsec).UTC()
	}
	return mtime, atime
}
