Fix putall to not erase volume (#15)

This commit is contained in:
Terence Boldt 2022-12-31 09:14:27 -05:00 committed by GitHub
parent 4ed23e0e6f
commit 592f3a6542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -17,7 +17,7 @@ import (
"github.com/tjboldt/ProDOS-Utilities/prodos"
)
const version = "0.4.0"
const version = "0.4.1"
func main() {
var fileName string
@ -155,7 +155,7 @@ func main() {
return
}
defer file.Close()
err = prodos.AddFilesFromHostDirectory(file, inFileName, volumeName, volumeSize)
err = prodos.AddFilesFromHostDirectory(file, inFileName)
if err != nil {
fmt.Printf("failed to add host files: %s\n", err)
return

View File

@ -164,6 +164,7 @@ func ConvertBasicToText(basic []byte) string {
}
}
// ConvertTextToBasic converts text to AppleSoft BASIC
func ConvertTextToBasic(text string) ([]byte, error) {
// convert line endings
text = strings.Replace(text, "\r\n", "\n", -1)

View File

@ -426,6 +426,7 @@ func createBlockList(reader io.ReaderAt, fileSize int) ([]int, error) {
return blockList, nil
}
// GetFileEntry returns a file entry for the given path
func GetFileEntry(reader io.ReaderAt, path string) (FileEntry, error) {
directory, fileName := GetDirectoryAndFileNameFromPath(path)
_, _, fileEntries, err := ReadDirectory(reader, directory)

View File

@ -15,10 +15,7 @@ import (
// from the specified host directory
func AddFilesFromHostDirectory(
readerWriter ReaderWriterAt,
directory string,
volumeName string,
numberOfBlocks int) error {
CreateVolume(readerWriter, volumeName, numberOfBlocks)
directory string) error {
files, err := os.ReadDir(directory)
if err != nil {

View File

@ -12,6 +12,7 @@ type MemoryFile struct {
size int
}
// ReaderWriterAt is an interface for both ReaderAt and WriterAt combined
type ReaderWriterAt interface {
ReadAt(data []byte, offset int64) (int, error)
WriteAt(data []byte, offset int64) (int, error)