diff --git a/build.sh b/build.sh index 74642f5..e3ea3b3 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,9 @@ #!/bin/bash + +# Copyright Terence J. Boldt (c)2021-2024 +# Use of this source code is governed by an MIT +# license that can be found in the LICENSE file. + GOOS=darwin GOARCH=arm64 go build -o binaries/macos/apple-silicon/ProDOS-Utilities GOOS=darwin GOARCH=amd64 go build -o binaries/macos/intel/ProDOS-Utilities GOOS=windows GOARCH=amd64 go build -o binaries/windows/intel/ProDOS-Utilities.exe diff --git a/main.go b/main.go index 631b871..5937717 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -17,7 +17,7 @@ import ( "github.com/tjboldt/ProDOS-Utilities/prodos" ) -const version = "0.4.9" +const version = "0.5.0" func main() { var fileName string diff --git a/prodos/basic.go b/prodos/basic.go index 57befbf..5c613f1 100644 --- a/prodos/basic.go +++ b/prodos/basic.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/basic_test.go b/prodos/basic_test.go index 69b503e..168f6fa 100644 --- a/prodos/basic_test.go +++ b/prodos/basic_test.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2022-2023 +// Copyright Terence J. Boldt (c)2022-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/bitmap.go b/prodos/bitmap.go index b612e93..7a509e9 100644 --- a/prodos/bitmap.go +++ b/prodos/bitmap.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/bitmap_test.go b/prodos/bitmap_test.go index c4dc85b..d464e7b 100644 --- a/prodos/bitmap_test.go +++ b/prodos/bitmap_test.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/block.go b/prodos/block.go index 0730d8b..2938e8c 100644 --- a/prodos/block.go +++ b/prodos/block.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/directory.go b/prodos/directory.go index 35d4948..0a379ea 100644 --- a/prodos/directory.go +++ b/prodos/directory.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -161,7 +161,10 @@ func CreateDirectory(readerWriter ReaderWriterAt, path string) error { fileEntry.Version = 0x24 fileEntry.MinVersion = 0x00 - writeFileEntry(readerWriter, fileEntry) + err = writeFileEntry(readerWriter, fileEntry) + if err != nil { + return err + } err = incrementFileCount(readerWriter, fileEntry) if err != nil { @@ -300,7 +303,10 @@ func expandDirectory(readerWriter ReaderWriterAt, buffer []byte, blockNumber uin directoryFileEntry := parseFileEntry(buffer[directoryEntryOffset:directoryEntryOffset+0x28], directoryHeader.ParentBlock, directoryHeader.ParentEntry*uint16(directoryHeader.EntryLength)+0x04) directoryFileEntry.BlocksUsed++ directoryFileEntry.EndOfFile += 0x200 - writeFileEntry(readerWriter, directoryFileEntry) + err = writeFileEntry(readerWriter, directoryFileEntry) + if err != nil { + return 0, err + } return nextBlockNumber, nil } @@ -396,7 +402,7 @@ func parseFileEntry(buffer []byte, blockNumber uint16, entryOffset uint16) FileE return fileEntry } -func writeFileEntry(writer io.WriterAt, fileEntry FileEntry) { +func writeFileEntry(writer io.WriterAt, fileEntry FileEntry) error { buffer := make([]byte, 39) buffer[0] = byte(fileEntry.StorageType)<<4 + byte(len(fileEntry.FileName)) for i := 0; i < len(fileEntry.FileName); i++ { @@ -429,8 +435,10 @@ func writeFileEntry(writer io.WriterAt, fileEntry FileEntry) { //fmt.Printf("Writing file entry at block: %04X offset: %04X\n", fileEntry.DirectoryBlock, fileEntry.DirectoryOffset) _, err := writer.WriteAt(buffer, int64(fileEntry.DirectoryBlock)*512+int64(fileEntry.DirectoryOffset)) if err != nil { - + return err } + + return nil } func parseVolumeHeader(buffer []byte) VolumeHeader { diff --git a/prodos/doc.go b/prodos/doc.go index a9ba97d..de5d2ca 100644 --- a/prodos/doc.go +++ b/prodos/doc.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/file.go b/prodos/file.go index c642b2c..3167384 100644 --- a/prodos/file.go +++ b/prodos/file.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -106,8 +106,10 @@ func WriteFile(readerWriter ReaderWriterAt, path string, fileType uint8, auxType fileEntry.StorageType = StorageTree } - writeFileEntry(readerWriter, fileEntry) - + err = writeFileEntry(readerWriter, fileEntry) + if err != nil { + return err + } return incrementFileCount(readerWriter, fileEntry) } @@ -168,7 +170,10 @@ func DeleteFile(readerWriter ReaderWriterAt, path string) error { // zero out directory entry fileEntry.StorageType = 0 fileEntry.FileName = "" - writeFileEntry(readerWriter, fileEntry) + err = writeFileEntry(readerWriter, fileEntry) + if err != nil { + return err + } return nil } @@ -422,7 +427,7 @@ func GetFileEntry(reader io.ReaderAt, path string) (FileEntry, error) { return FileEntry{}, err } - if fileEntries == nil || len(fileEntries) == 0 { + if len(fileEntries) == 0 { return FileEntry{}, errors.New("file entry not found") } diff --git a/prodos/file_test.go b/prodos/file_test.go index 84db15b..37ac6ab 100644 --- a/prodos/file_test.go +++ b/prodos/file_test.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/format.go b/prodos/format.go index d276019..5b9c3e8 100644 --- a/prodos/format.go +++ b/prodos/format.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/format_test.go b/prodos/format_test.go index 3770da5..544dee0 100644 --- a/prodos/format_test.go +++ b/prodos/format_test.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/host.go b/prodos/host.go index 099befa..42f953f 100644 --- a/prodos/host.go +++ b/prodos/host.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2022-2023 +// Copyright Terence J. Boldt (c)2022-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -28,6 +28,9 @@ func AddFilesFromHostDirectory( ) error { path, err := makeFullPath(path, readerWriter) + if err != nil { + return err + } if !strings.HasSuffix(path, "/") { path = path + "/" diff --git a/prodos/image.go b/prodos/image.go index f4d1b35..5f27d6a 100644 --- a/prodos/image.go +++ b/prodos/image.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/memfile.go b/prodos/memfile.go index aeb674c..e03e047 100644 --- a/prodos/memfile.go +++ b/prodos/memfile.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/text.go b/prodos/text.go index 1e5ecd4..9bf5bf0 100644 --- a/prodos/text.go +++ b/prodos/text.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/time.go b/prodos/time.go index bb6f3e7..41a6ed5 100644 --- a/prodos/time.go +++ b/prodos/time.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/time_test.go b/prodos/time_test.go index 177f034..2afd84d 100644 --- a/prodos/time_test.go +++ b/prodos/time_test.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2023 +// Copyright Terence J. Boldt (c)2021-2024 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file.