github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/client/logging/rotatingfile_windows.go (about) 1 package logging 2 3 import ( 4 "time" 5 6 "golang.org/x/sys/windows" 7 ) 8 9 // IsTerminal returns whether the given file descriptor is a terminal. 10 var IsTerminal = func(fd int) bool { //nolint:gochecknoglobals // os specific func replacement 11 return false 12 } 13 14 // restoreCTimeAfterRename will restore the creation time on a file on Windows where 15 // the file otherwise gets the creation time of the existing file that the operation 16 // overwrites. 17 func restoreCTimeAfterRename(path string, ctime time.Time) error { 18 p16, e := windows.UTF16PtrFromString(path) 19 if e != nil { 20 return e 21 } 22 h, e := windows.CreateFile(p16, 23 windows.FILE_WRITE_ATTRIBUTES, windows.FILE_SHARE_WRITE, nil, 24 windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS, 0) 25 if e != nil { 26 return e 27 } 28 defer windows.Close(h) 29 c := windows.NsecToFiletime(ctime.UnixNano()) 30 return windows.SetFileTime(h, &c, nil, nil) 31 }