Files
FWS-Kitty/kittens/dnd/birth_time_linux.go
T
BlackAngelTV 7e7d249099 chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty,
vendored at upstream commit 91fb38a without its git history.
2026-11-04 11:20:47 +01:00

33 lines
789 B
Go

package dnd
import (
"os"
"time"
"golang.org/x/sys/unix"
)
// Return the birth time of the file at path, which must be the file
// described by info, or the zero time if it is unknown.
func birth_time(path string, info os.FileInfo) time.Time {
var sx unix.Statx_t
for {
err := unix.Statx(unix.AT_FDCWD, path, unix.AT_SYMLINK_NOFOLLOW, unix.STATX_INO|unix.STATX_BTIME, &sx)
if err == nil {
break
}
if err != unix.EINTR {
return time.Time{}
}
}
if sx.Mask&unix.STATX_BTIME == 0 {
return time.Time{}
}
// The path may have been replaced since info was obtained
dev, ino, err := file_identity(info)
if err != nil || ino != sx.Ino || dev != unix.Mkdev(sx.Dev_major, sx.Dev_minor) {
return time.Time{}
}
return time.Unix(sx.Btime.Sec, int64(sx.Btime.Nsec))
}