Learn R Programming

adfExplorer (version 2.0.3)

read_adf_block: Read or write raw data blocks to a virtual device

Description

The Amiga file system is structured around 512 byte blocks. A double density floppy disk consists of 1760 blocks of 512 bytes. read_adf_block and write_adf_block can be used to transform raw data from and to virtual devices (created with create_adf_device() or connect_adf()). Note that writing raw data to a disk could corrupt the file system on the device. So it is generally not advised unless you know what you are doing.

Usage

read_adf_block(dev, sector, ...)

# S3 method for adf_device read_adf_block(dev, sector, ...)

write_adf_block(dev, sector, data, ...)

# S3 method for adf_device write_adf_block(dev, sector, data, ...)

# S3 method for raw write_adf_block.adf_device(dev, sector, data, ...)

# S3 method for adf_block write_adf_block.adf_device(dev, sector, data, ...)

# S3 method for default write_adf_block.adf_device(dev, sector, data, ...)

as_adf_block(data, ...)

new_adf_block()

Value

In case of write_adf_block

NULL is returned invisibly. In case of read_adf_block

the raw data is returned as a adf_block class object.

Arguments

dev

The virtual adf device for which information needs to be obtained. It should be of class adf_device which can be created with create_adf_device() or connect_adf().

sector

Sector ID of the block you wish to read/write. It is an integer value. For double density disks, the ID ranges from 0 to 1759.

...

Ignored

data

Block data (raw vector of length 512) you wish to write to a virtual device

Author

Pepijn de Vries

Examples

Run this code
my_device <- demo_adf(write_protected = FALSE)

info <- adf_entry_info(my_device, "S/startup-sequence")

filedata_block <- read_adf_block(my_device, rev(info[[1]]$dataBlocks)[[1]])
filedata_block

empty_block <- new_adf_block()
empty_block <- as_adf_block(raw(512L))

## Write some random data to block 5 on the device
## Note that this could break the file system on the virtual device!
write_adf_block(my_device, 5, as.raw(runif(512, 0, 255)))
## converting the data to an adf block object first
## is optional:
write_adf_block(my_device, 6, as_adf_block(as.raw(runif(512, 0, 255))))
close(my_device)

Run the code above in your browser using DataLab