diff --git a/README.md b/README.md index d546017..b2b5aeb 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,10 @@ Being a work in progress, be warned that this code is likely to corrupt drive im There are binaries [here](https://github.com/tjboldt/ProDOS-Utilities/releases/latest) ## Current TODO list -1. Allow > 128 KB file support -2. Create/Delete directories -3. Add file/directory tests -4. Add rename -5. Add in-place file/directory moves +1. Create/Delete directories +2. Add file/directory tests +3. Add rename +4. Add in-place file/directory moves ## Example commands and output diff --git a/main.go b/main.go index aacaf51..2836a45 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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.1" +const version = "0.4.2" func main() { var fileName string diff --git a/prodos/basic.go b/prodos/basic.go index 5360b03..f1799d3 100644 --- a/prodos/basic.go +++ b/prodos/basic.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 55d95b4..69b503e 100644 --- a/prodos/basic_test.go +++ b/prodos/basic_test.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2022-2023 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file provides tests for conversion between BASIC and text + package prodos import ( diff --git a/prodos/bitmap.go b/prodos/bitmap.go index 07e5bf0..3e6a401 100644 --- a/prodos/bitmap.go +++ b/prodos/bitmap.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 ac152b5..2ea6a40 100644 --- a/prodos/bitmap_test.go +++ b/prodos/bitmap_test.go @@ -1,3 +1,10 @@ +// Copyright Terence J. Boldt (c)2021-2023 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file provides tests for access to volum bitmap on +// a ProDOS drive image + package prodos import ( diff --git a/prodos/block.go b/prodos/block.go index 6fbf4df..dd94d54 100644 --- a/prodos/block.go +++ b/prodos/block.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 13098b9..6e9ec84 100644 --- a/prodos/directory.go +++ b/prodos/directory.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. diff --git a/prodos/doc.go b/prodos/doc.go index eadf65d..a9ba97d 100644 --- a/prodos/doc.go +++ b/prodos/doc.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 f8bba50..4b6bd38 100644 --- a/prodos/file.go +++ b/prodos/file.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -257,23 +257,21 @@ func getBlocklist(reader io.ReaderAt, fileEntry FileEntry, dataOnly bool) ([]int return blocks, nil case StorageTree: dataBlocks := make([]int, fileEntry.BlocksUsed) + indexBlocks := make([]int, fileEntry.BlocksUsed/256+1) masterIndex, err := ReadBlock(reader, fileEntry.KeyPointer) if err != nil { return nil, err } - blockOffset := 0 - if !dataOnly { - blocks[0] = fileEntry.KeyPointer - blockOffset = 1 - } + indexBlocks[0] = fileEntry.KeyPointer + indexBlockCount := 1 + for i := 0; i < 128; i++ { indexBlock := int(masterIndex[i]) + int(masterIndex[i+256])*256 if indexBlock == 0 { break } - if !dataOnly { - blockOffset++ - } + indexBlocks[indexBlockCount] = indexBlock + indexBlockCount++ index, err := ReadBlock(reader, indexBlock) if err != nil { return nil, err @@ -290,7 +288,7 @@ func getBlocklist(reader io.ReaderAt, fileEntry FileEntry, dataOnly bool) ([]int return dataBlocks, nil } - blocks = append(blocks[blockOffset:], dataBlocks...) + blocks = append(indexBlocks, dataBlocks...) return blocks, nil } diff --git a/prodos/file_test.go b/prodos/file_test.go index 3736093..af222ad 100644 --- a/prodos/file_test.go +++ b/prodos/file_test.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 e2458c0..a2a42ed 100644 --- a/prodos/format_test.go +++ b/prodos/format_test.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2021-2023 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file provides tests for access to format a ProDOS drive image + package prodos import ( diff --git a/prodos/host.go b/prodos/host.go index 77365d1..d05e90a 100644 --- a/prodos/host.go +++ b/prodos/host.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2022 +// Copyright Terence J. Boldt (c)2022-2023 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -30,7 +30,7 @@ func AddFilesFromHostDirectory( return err } - if !file.IsDir() && info.Size() > 0 && info.Size() <= 0x20000 { + if !file.IsDir() && info.Size() > 0 && info.Size() <= 0x1000000 { err = WriteFileFromFile(readerWriter, "", 0, 0, filepath.Join(directory, file.Name())) if err != nil { return err diff --git a/prodos/memfile.go b/prodos/memfile.go index 82f8abb..aeb674c 100644 --- a/prodos/memfile.go +++ b/prodos/memfile.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 bc214eb..5bf55bf 100644 --- a/prodos/text.go +++ b/prodos/text.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // 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 ff4fb0d..bb6f3e7 100644 --- a/prodos/time.go +++ b/prodos/time.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -11,19 +11,20 @@ import ( ) // DateTimeToProDOS converts Time to ProDOS date time -// 49041 ($BF91) 49040 ($BF90) // -// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 -// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ -// DATE: | year | month | day | -// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +// 49041 ($BF91) 49040 ($BF90) // -// 49043 ($BF93) 49042 ($BF92) +// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 +// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +// DATE: | year | month | day | +// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ // -// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 -// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ -// TIME: | hour | | minute | -// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +// 49043 ($BF93) 49042 ($BF92) +// +// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 +// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +// TIME: | hour | | minute | +// +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ func DateTimeToProDOS(dateTime time.Time) []byte { year := dateTime.Year() % 100 month := dateTime.Month() diff --git a/prodos/time_test.go b/prodos/time_test.go index 66710f2..177f034 100644 --- a/prodos/time_test.go +++ b/prodos/time_test.go @@ -1,3 +1,9 @@ +// Copyright Terence J. Boldt (c)2021-2023 +// Use of this source code is governed by an MIT +// license that can be found in the LICENSE file. + +// This file provides tests for conversion to and from ProDOS time format + package prodos import ( diff --git a/readme.go b/readme.go index fc42870..e254ec2 100644 --- a/readme.go +++ b/readme.go @@ -1,4 +1,4 @@ -// Copyright Terence J. Boldt (c)2021-2022 +// Copyright Terence J. Boldt (c)2021-2023 // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. @@ -14,7 +14,7 @@ func printReadme() { fmt.Println(` MIT License -Copyright (c)2021-2022 Terence Boldt +Copyright (c)2021-2023 Terence Boldt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal