additional tools

This commit is contained in:
Kujtim Hoxha
2025-03-25 13:04:36 +01:00
parent 005b8ac167
commit 904061c243
33 changed files with 3258 additions and 236 deletions

View File

@@ -0,0 +1,53 @@
package tools
import (
"sync"
"time"
)
// File record to track when files were read/written
type fileRecord struct {
path string
readTime time.Time
writeTime time.Time
}
var (
fileRecords = make(map[string]fileRecord)
fileRecordMutex sync.RWMutex
)
func recordFileRead(path string) {
fileRecordMutex.Lock()
defer fileRecordMutex.Unlock()
record, exists := fileRecords[path]
if !exists {
record = fileRecord{path: path}
}
record.readTime = time.Now()
fileRecords[path] = record
}
func getLastReadTime(path string) time.Time {
fileRecordMutex.RLock()
defer fileRecordMutex.RUnlock()
record, exists := fileRecords[path]
if !exists {
return time.Time{}
}
return record.readTime
}
func recordFileWrite(path string) {
fileRecordMutex.Lock()
defer fileRecordMutex.Unlock()
record, exists := fileRecords[path]
if !exists {
record = fileRecord{path: path}
}
record.writeTime = time.Now()
fileRecords[path] = record
}