package snapshot import ( "os" "syscall" "time" ) // getCTime extracts the file creation time (birth time) from os.FileInfo. // // On macOS (Darwin), this returns the birth time (Birthtimespec) from the // underlying syscall.Stat_t. macOS HFS+ and APFS filesystems natively track // file creation time, making this a true "created at" timestamp. // // Falls back to modification time if the underlying Sys() data is not a // *syscall.Stat_t (e.g. when using in-memory filesystems for testing). func getCTime(info os.FileInfo) time.Time { stat, ok := info.Sys().(*syscall.Stat_t) if !ok { return info.ModTime() } return time.Unix(stat.Birthtimespec.Sec, stat.Birthtimespec.Nsec).UTC() }