- SEE ALSO
- COPYRIGHT AND LICENSE
D64::Disk::Image::File - File I/O portion of Perl interface to Per Olofsson's "diskimage.c", an ANSI C library for manipulating Commodore disk images
use D64::Disk::Image qw(:all); # Load an image from disk: my $d64 = D64::Disk::Image->load_image('disk.d64'); # Write data to file: my $rawname = $d64->rawname_from_name('testfile'); my $prg = $d64->open($rawname, T_PRG, F_WRITE); my $counter = $prg->write($buffer); $prg->close(); # Read data from file: my $rawname = $d64->rawname_from_name('testfile'); my $prg = $d64->open($rawname, T_PRG, F_READ); my ($counter, $buffer) = $prg->read(); $prg->close(); # Write the image to disk: $d64->free_image();
Per Olofsson's "diskimage.c" is an ANSI C library for manipulating Commodore disk images. In Perl the following operations are implemented via D64::Disk::Image::File package:
Open file ('$' reads directory)
Create new D64::Disk::Image::File object and open file on a disk image:
my $imageFile = D64::Disk::Image::File->new($diskImage, $rawname, $fileType, $mode); my $imageFile = D64::Disk::Image::File->open($diskImage, $rawname, $fileType, $mode);
Opens a file for reading or writing. Mode should be either F_READ (for reading) or F_WRITE (for writing). If '$' is given instead of the raw filename, the directory will be read. Consult D64::Disk::Image module documentation for the list of available file types. All parameters are mandatory.
Close a file (each opened file needs to be subsequently closed to avoid memory leaks):
Read data from file opened in F_READ mode:
my ($counter, $buffer) = $imageFile->read($maxlength);
Reads $maxlength bytes of data into the buffer. Returns the number of bytes actually read, and the buffer with succeeding bytes of data.
Write data to file opened in F_WRITE mode:
my $counter = $imageFile->write($buffer, $length);
Writes $length bytes of data from the $buffer. Returns the number of bytes actually written.
There are no known bugs at the moment. Please report any bugs or feature requests.
D64::Disk::Image::File exports nothing by default.
You may request the import of open mode constants (
F_WRITE). Both these constants can be explicitly imported from
D64::Disk::Image::File by using it with ":modes" tag. All constants can be explicitly imported from
D64::Disk::Image::File by using it with ":all" tag.
Pawel Krol, <firstname.lastname@example.org>.
Version 0.05 (2018-12-01)
diskimage.c is released under a slightly modified BSD license.
Copyright (c) 2003-2006, Per Olofsson All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diskimage.c website: https://paradroid.automac.se/diskimage/