From 592f3a65428f518aa21dd4383121894081f7a7db Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Sat, 31 Dec 2022 09:14:27 -0500 Subject: [PATCH] Fix putall to not erase volume (#15) --- main.go | 4 ++-- prodos/basic.go | 1 + prodos/file.go | 1 + prodos/host.go | 5 +---- prodos/memfile.go | 1 + 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 3051c5f..aacaf51 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/prodos/basic.go b/prodos/basic.go index 953d784..5360b03 100644 --- a/prodos/basic.go +++ b/prodos/basic.go @@ -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) diff --git a/prodos/file.go b/prodos/file.go index c2b27ed..77a84ff 100644 --- a/prodos/file.go +++ b/prodos/file.go @@ -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) diff --git a/prodos/host.go b/prodos/host.go index f1851f7..f463569 100644 --- a/prodos/host.go +++ b/prodos/host.go @@ -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 { diff --git a/prodos/memfile.go b/prodos/memfile.go index 08521e8..82f8abb 100644 --- a/prodos/memfile.go +++ b/prodos/memfile.go @@ -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)