ProDOS-Utilities/prodos/block.go

28 lines
696 B
Go
Raw Normal View History

// 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 access to read and write
// blocks on a ProDOS drive image
2021-06-09 12:23:18 +00:00
package prodos
import (
"io"
2021-06-09 12:23:18 +00:00
)
2022-01-23 22:30:18 +00:00
// ReadBlock reads a block from a ProDOS volume into a byte array
func ReadBlock(reader io.ReaderAt, block int) ([]byte, error) {
2021-06-09 12:23:18 +00:00
buffer := make([]byte, 512)
_, err := reader.ReadAt(buffer, int64(block)*512)
2021-06-09 12:23:18 +00:00
return buffer, err
2021-06-09 12:23:18 +00:00
}
2022-01-23 22:30:18 +00:00
// WriteBlock writes a block to a ProDOS volume from a byte array
func WriteBlock(writer io.WriterAt, block int, buffer []byte) error {
_, err := writer.WriteAt(buffer, int64(block)*512)
return err
2021-06-09 12:23:18 +00:00
}