mirror of
https://github.com/tjboldt/ProDOS-Utilities.git
synced 2024-11-28 12:51:35 +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)
|
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 {
|
if err != nil {
|
||||||
fmt.Printf("Failed to write file %s", err)
|
fmt.Printf("Failed to write file %s", err)
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -41,6 +42,8 @@ func AddFilesFromHostDirectory(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cacheDir := getCacheDir(files)
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
info, err := file.Info()
|
info, err := file.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -48,7 +51,7 @@ func AddFilesFromHostDirectory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file.Name()[0] != '.' && !file.IsDir() && info.Size() > 0 && info.Size() <= 0x1000000 {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -84,6 +87,7 @@ func WriteFileFromFile(
|
|||||||
auxType uint16,
|
auxType uint16,
|
||||||
modifiedTime time.Time,
|
modifiedTime time.Time,
|
||||||
inFileName string,
|
inFileName string,
|
||||||
|
cacheDir fs.DirEntry,
|
||||||
ignoreDuplicates bool,
|
ignoreDuplicates bool,
|
||||||
) error {
|
) error {
|
||||||
|
|
||||||
@ -268,3 +272,13 @@ func isAppleSingleMagicNumber(inFile []byte) bool {
|
|||||||
}
|
}
|
||||||
return false
|
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