photoprism/pkg/fs/birthtime.go

23 lines
310 B
Go
Raw Normal View History

2020-12-09 12:10:21 +00:00
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()
}