tlog.app/go/tlog@v0.23.1/rotating/ctime_windows.go (about)

     1  package rotating
     2  
     3  import (
     4  	"io/fs"
     5  	"syscall"
     6  	"time"
     7  )
     8  
     9  func fileCtime(fstat func(string) (fs.FileInfo, error), name string, now time.Time) time.Time {
    10  	inf, err := fstat(name)
    11  	if err != nil {
    12  		return now
    13  	}
    14  
    15  	return ctime(inf, now)
    16  }
    17  
    18  func ctime(inf fs.FileInfo, now time.Time) time.Time {
    19  	stat, ok := inf.Sys().(*syscall.Win32FileAttributeData)
    20  	if !ok {
    21  		return now
    22  	}
    23  
    24  	return time.Unix(0, stat.CreationTime.Nanoseconds())
    25  }