backuper/filehistory.go
nxshock 19e809966a Rework
* update logger routines
* add index file support
* split file masks and path masks
2023-04-03 19:43:16 +05:00

29 lines
773 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
// FileHistory содержит историю изменения файла
type FileHistory []FileInfo
// Latest возвращает информацию о последней версии файла
func (fileHistory FileHistory) Latest() FileInfo {
file := fileHistory[0]
for i := 1; i < len(fileHistory); i++ {
if fileHistory[i].ModificationTime.After(file.ModificationTime) {
file = fileHistory[i]
}
}
return file
}
func (fileHistory FileHistory) Len() int {
return len(fileHistory)
}
func (fileHistory FileHistory) Swap(i, j int) {
fileHistory[i], fileHistory[j] = fileHistory[j], fileHistory[i]
}
func (fileHistory FileHistory) Less(i, j int) bool {
return fileHistory[i].ModificationTime.Before(fileHistory[j].ModificationTime)
}