2020-09-27 19:24:08 +00:00
|
|
|
package filesystem
|
2019-04-07 21:45:23 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"time"
|
2024-03-13 03:44:55 +00:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2019-04-07 21:45:23 +00:00
|
|
|
)
|
|
|
|
|
2024-03-13 03:44:55 +00:00
|
|
|
// CTime returns the time that the file/folder was created.
|
|
|
|
//
|
|
|
|
// TODO: remove. Ctim is not actually ever been correct and doesn't actually
|
|
|
|
// return the creation time.
|
2019-04-07 21:45:23 +00:00
|
|
|
func (s *Stat) CTime() time.Time {
|
2024-03-13 03:44:55 +00:00
|
|
|
if st, ok := s.Sys().(*unix.Stat_t); ok {
|
|
|
|
// Do not remove these "redundant" type-casts, they are required for 32-bit builds to work.
|
|
|
|
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
|
|
|
|
}
|
|
|
|
if st, ok := s.Sys().(*syscall.Stat_t); ok {
|
|
|
|
// Do not remove these "redundant" type-casts, they are required for 32-bit builds to work.
|
|
|
|
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
|
|
|
|
}
|
|
|
|
return time.Time{}
|
2020-09-05 19:08:40 +00:00
|
|
|
}
|