1package tools
 2
 3import (
 4	"sync"
 5	"time"
 6)
 7
 8// File record to track when files were read/written
 9type fileRecord struct {
10	path      string
11	readTime  time.Time
12	writeTime time.Time
13}
14
15var (
16	fileRecords     = make(map[string]fileRecord)
17	fileRecordMutex sync.RWMutex
18)
19
20func recordFileRead(path string) {
21	fileRecordMutex.Lock()
22	defer fileRecordMutex.Unlock()
23
24	record, exists := fileRecords[path]
25	if !exists {
26		record = fileRecord{path: path}
27	}
28	record.readTime = time.Now()
29	fileRecords[path] = record
30}
31
32func getLastReadTime(path string) time.Time {
33	fileRecordMutex.RLock()
34	defer fileRecordMutex.RUnlock()
35
36	record, exists := fileRecords[path]
37	if !exists {
38		return time.Time{}
39	}
40	return record.readTime
41}
42
43func recordFileWrite(path string) {
44	fileRecordMutex.Lock()
45	defer fileRecordMutex.Unlock()
46
47	record, exists := fileRecords[path]
48	if !exists {
49		record = fileRecord{path: path}
50	}
51	record.writeTime = time.Now()
52	fileRecords[path] = record
53}