mirror of
https://github.com/stevenhowes/GoRetro.git
synced 2026-05-27 00:03:29 +01:00
File caching and stats for tex/file caches.
This commit is contained in:
+17
-4
@@ -8,18 +8,31 @@ package GoRetro
|
||||
* the use of archive files etc in future.
|
||||
*/
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type vFile struct {
|
||||
Data []byte
|
||||
Size int
|
||||
}
|
||||
|
||||
func GetFile(filename string) *vFile {
|
||||
Data, _ := os.ReadFile(Config.DataDir + filename)
|
||||
var FileList map[string]*vFile
|
||||
|
||||
func GetFile(filename string) (*vFile, error) {
|
||||
if val, ok := FileList[filename]; ok {
|
||||
CacheHitsFile++
|
||||
return val, nil
|
||||
}
|
||||
|
||||
Data, err := os.ReadFile(Config.DataDir + filename)
|
||||
vf := vFile{
|
||||
Size: len(Data),
|
||||
Data: Data,
|
||||
}
|
||||
return &vf
|
||||
|
||||
fmt.Printf("File Caching %s\n", filename)
|
||||
FileList[filename] = &vf
|
||||
return &vf, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user