Files
steamcache2/vfs/fileinfo.go
Justin Harms 6919358eab
All checks were successful
Release Tag / release (push) Successful in 13s
Enhance file metadata tracking and garbage collection logic
- Added AccessCount field to FileInfo struct for improved tracking of file access frequency.
- Updated NewFileInfo and NewFileInfoFromOS functions to initialize AccessCount.
- Modified DiskFS and MemoryFS to preserve and increment AccessCount during file operations.
- Enhanced garbage collection methods (LRU, LFU, FIFO, Largest, Smallest, Hybrid) to utilize AccessCount for more effective space reclamation.
2025-07-19 09:07:49 -05:00

52 lines
869 B
Go

// vfs/fileinfo.go
package vfs
import (
"os"
"time"
)
type FileInfo struct {
name string
size int64
MTime time.Time
ATime time.Time
AccessCount int64 // Number of times the file has been accessed
}
func NewFileInfo(key string, size int64, modTime time.Time) *FileInfo {
return &FileInfo{
name: key,
size: size,
MTime: modTime,
ATime: time.Now(),
AccessCount: 0,
}
}
func NewFileInfoFromOS(f os.FileInfo, key string) *FileInfo {
return &FileInfo{
name: key,
size: f.Size(),
MTime: f.ModTime(),
ATime: time.Now(),
AccessCount: 0,
}
}
func (f FileInfo) Name() string {
return f.name
}
func (f FileInfo) Size() int64 {
return f.size
}
func (f FileInfo) ModTime() time.Time {
return f.MTime
}
func (f FileInfo) AccessTime() time.Time {
return f.ATime
}