photoprism/pkg/fs/birthtime.go
2020-12-09 13:10:21 +01:00

22 lines
310 B
Go

package fs
import (
"time"
"github.com/djherbis/times"
)
// BirthTime returns the create time of a file or folder.
func BirthTime(fileName string) time.Time {
s, err := times.Stat(fileName)
if err != nil {
return time.Now()
}
if s.HasBirthTime() {
return s.BirthTime()
}
return s.ModTime()
}