mirror of
https://github.com/tjboldt/ProDOS-Utilities.git
synced 2024-12-26 14:29:36 +00:00
Add support for reading from cache
This commit is contained in:
parent
dbd576be4e
commit
6925946526
2
main.go
2
main.go
@ -214,7 +214,7 @@ func put(fileName string, pathName string, fileType uint8, auxType uint16, inFil
|
||||
fmt.Printf("Failed get fileInfo for %s - %s", fileName, err)
|
||||
}
|
||||
|
||||
err = prodos.WriteFileFromFile(file, pathName, fileType, auxType, fileInfo.ModTime(), inFileName, false)
|
||||
err = prodos.WriteFileFromFile(file, pathName, fileType, auxType, fileInfo.ModTime(), inFileName, nil, false)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to write file %s", err)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@ -41,6 +42,8 @@ func AddFilesFromHostDirectory(
|
||||
return err
|
||||
}
|
||||
|
||||
cacheDir := getCacheDir(files)
|
||||
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
@ -48,7 +51,7 @@ func AddFilesFromHostDirectory(
|
||||
}
|
||||
|
||||
if file.Name()[0] != '.' && !file.IsDir() && info.Size() > 0 && info.Size() <= 0x1000000 {
|
||||
err = WriteFileFromFile(readerWriter, path, 0, 0, info.ModTime(), filepath.Join(directory, file.Name()), true)
|
||||
err = WriteFileFromFile(readerWriter, path, 0, 0, info.ModTime(), filepath.Join(directory, file.Name()), cacheDir, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -84,6 +87,7 @@ func WriteFileFromFile(
|
||||
auxType uint16,
|
||||
modifiedTime time.Time,
|
||||
inFileName string,
|
||||
cacheDir fs.DirEntry,
|
||||
ignoreDuplicates bool,
|
||||
) error {
|
||||
|
||||
@ -268,3 +272,13 @@ func isAppleSingleMagicNumber(inFile []byte) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getCacheDir(files []fs.DirEntry) fs.DirEntry {
|
||||
for _, file := range files {
|
||||
if file.Name() == ".prodoscache" {
|
||||
return file
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user