NAME
D64::Disk::Dir::Entry - Handling individual Commodore (D64/D71/D81) disk image directory entries
SYNOPSIS
use D64::Disk::Dir::Entry;
# Create a new directory entry and initialize it with 30 bytes of binary data retrieved from a D64 disk image:
my $entryObj = D64::Disk::Dir::Entry->new($bytes);
# Get filename converted to ASCII string:
my $convert2ascii = 1;
my $name = $entryObj->get_name($convert2ascii);
# Get various parameters describing detailed entry properties:
my $type = $entryObj->get_type();
my $track = $entryObj->get_track();
my $sector = $entryObj->get_sector();
# Print out a single line out of entire disk directory with the contents of this particular entry to the standard output:
$entryObj->print_entry();
DESCRIPTION
This package provides a helper class for D64::Disk::Dir module, enabling user to handle individual directory entries in a higher-level object-oriented way.
METHODS
new
Create new D64::Disk::Dir::Entry
object and initialize it with 30 bytes of binary data describing each directory entry on a D64 disk image (or a physical disk):
my $entryObj = D64::Disk::Dir::Entry->new($bytes);
The reason for initializing object not with 32 bytes of physical data but with 30 bytes instead is that two first bytes of each entry in a directory sector always should be $00 $00 as they are unused (except for the very first entry, in which case those bytes are still directory-wide, not entry-specific).
A valid D64::Disk::Dir::Entry
object is returned upon success, an undefined value otherwise.
get_type
Get the actual filetype:
my $type = $entryObj->get_type();
Returns the actual filetype as a three-letter string, the possibilities here are: "del", "seq", "prg", "usr", "rel", "cbm", "dir", and "???".
set_type
Set the actual filetype:
my $type = T_DEL;
$entryObj->set_type($type);
Sets the actual filetype as a symbollic type name, the possibilities here are: T_DEL
, T_SEQ
, T_PRG
, T_USR
, T_REL
, T_CBM
, and T_DIR
.
get_closed
Get "Closed" flag (when not set produces "*", or "splat" files):
my $closed = $entryObj->get_closed();
Returns true when "Closed" flag is set, and false otherwise.
set_closed
Set "Closed" flag:
$entryObj->set_closed(1);
Clear "Closed" flag:
$entryObj->set_closed(0);
get_locked
Get "Locked" flag (when set produces ">" locked files):
my $locked = $entryObj->get_locked();
Returns true when "Locked" flag is set, and false otherwise.
get_track
Get track location of first sector of file:
my $track = $entryObj->get_track();
set_track
Set track location of first sector of file:
$entryObj->get_track($track);
get_sector
Get sector location of first sector of file:
my $sector = $entryObj->get_sector();
set_sector
Set sector location of first sector of file:
$entryObj->set_sector($sector);
get_name
Get 16 character filename (in PETASCII, padded with $A0):
my $convert2ascii = 0;
my $name = $entryObj->get_name($convert2ascii);
Get filename converted to ASCII string:
my $convert2ascii = 1;
my $name = $entryObj->get_name($convert2ascii);
get_side_track
Get track location of first side-sector block (relative file only):
my $side_track = $entryObj->get_side_track();
A track location of first side-sector block is returned upon success, an undefined value otherwise.
get_side_sector
Get sector location of first side-sector block (relative file only):
my $side_sector = $entryObj->get_side_sector();
A sector location of first side-sector block is returned upon success, an undefined value otherwise.
get_record_length
Get relative file record length (relative file only, maximum value 254):
my $record_length = $entryObj->get_record_length();
A relative file record length is returned upon success, an undefined value otherwise.
get_size
Get file size in sectors:
my $size = $entryObj->get_size();
The approximate filesize in bytes is <= #sectors * 254.
get_bytes
Get 30 bytes of binary data that would describe this particular directory entry on a D64 disk image (or a physical disk):
my $bytes = $entryObj->get_bytes();
print_entry
Print entry details to any opened file handle (the standard output by default):
$entryObj->print_entry($fh, { verbose => $verbose });
This method is subsequently invoked for each single entry while printing an entire directory with D64::Disk::Dir module.
verbose
defaults to false (changing it to true will additionally print out file's track and sector values).
BUGS
There are no known bugs at the moment. Please report any bugs or feature requests.
EXPORT
None. No method is exported into the caller's namespace either by default or explicitly.
SEE ALSO
D64::Disk::Dir, D64::Disk::Image
AUTHOR
Pawel Krol, <pawelkrol@cpan.org>.
VERSION
Version 0.06 (2023-08-28)
COPYRIGHT AND LICENSE
This module is licensed under a slightly modified BSD license, the same terms as Per Olofsson's "diskimage.c" library and D64::Disk::Image Perl package it is based on, license contents are repeated below.
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/