| 1 | package D64::Disk::Dir; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | D64::Disk::Dir - Handling entire Commodore (D64/D71/D81) disk image directories (using Per Olofsson's "diskimage.c" library) | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | use D64::Disk::Dir; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # Read entire D64/D71/D81 disk image directory from file on disk in one step: | ||||||||||||||||||||||||||||
| 12 | my $d64DiskDirObj = D64::Disk::Dir->new($filename); | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Read entire D64/D71/D81 disk image directory from file on disk in two steps: | ||||||||||||||||||||||||||||
| 15 | my $d64DiskDirObj = D64::Disk::Dir->new(); | ||||||||||||||||||||||||||||
| 16 | my $readOK = $d64DiskDirObj->read_dir($filename); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Read new D64/D71/D81 disk directory replacing currently loaded dir with it: | ||||||||||||||||||||||||||||
| 19 | my $readOK = $d64DiskDirObj->read_dir($filename); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Get disk directory title converted to ASCII string: | ||||||||||||||||||||||||||||
| 22 | my $convert2ascii = 1; | ||||||||||||||||||||||||||||
| 23 | my $title = $d64DiskDirObj->get_title($convert2ascii); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # Get disk directory ID converted to ASCII string: | ||||||||||||||||||||||||||||
| 26 | my $convert2ascii = 1; | ||||||||||||||||||||||||||||
| 27 | my $diskID = $d64DiskDirObj->get_id($convert2ascii); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Get number of blocks free: | ||||||||||||||||||||||||||||
| 30 | my $blocksFree = $d64DiskDirObj->get_blocks_free(); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # Get number of directory entries: | ||||||||||||||||||||||||||||
| 33 | my $num_entries = $d64DiskDirObj->num_entries(); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Get directory entry at the specified position: | ||||||||||||||||||||||||||||
| 36 | my $entryObj = $d64DiskDirObj->get_entry($index); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # Get binary file data from a directory entry at the specified position: | ||||||||||||||||||||||||||||
| 39 | my $data = $d64DiskDirObj->get_file_data($index); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Print out the entire directory content to the standard output: | ||||||||||||||||||||||||||||
| 42 | $d64DiskDirObj->print_dir(); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | This package provides an abstract layer above D64::Disk::Image module, enabling user to handle D64 disk image directories in a higher-level object-oriented way. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 METHODS | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =cut | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 4 | ▶ | use base qw( Exporter ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 57 | 4 | our %EXPORT_TAGS = (); | |||||||||||||||||||||||||||
| 58 | 4 | $EXPORT_TAGS{'all'} = []; | |||||||||||||||||||||||||||
| 59 | 4 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||
| 60 | 4 | our @EXPORT = qw(); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 4 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 4 | ▶ | use Carp qw/carp croak verbose/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 4 | ▶ | use IO::Scalar; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 4 | ▶ | use Term::ANSIColor qw(:constants); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | ▶ | use D64::Disk::Dir::Entry; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | 4 | ▶ | use D64::Disk::Image qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # Mapping file types onto file type constants: | ||||||||||||||||||||||||||||
| 73 | 4 | our %file_type_constants = ( | |||||||||||||||||||||||||||
| 74 | 'del' => T_DEL, | ||||||||||||||||||||||||||||
| 75 | 'seq' => T_SEQ, | ||||||||||||||||||||||||||||
| 76 | 'prg' => T_PRG, | ||||||||||||||||||||||||||||
| 77 | 'usr' => T_USR, | ||||||||||||||||||||||||||||
| 78 | 'rel' => T_REL, | ||||||||||||||||||||||||||||
| 79 | 'cbm' => T_CBM, | ||||||||||||||||||||||||||||
| 80 | 'dir' => T_DIR, | ||||||||||||||||||||||||||||
| 81 | '???' => 0xFF, | ||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head2 new | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Create empty C<D64::Disk::Dir> object without loading disk image directory yet: | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | my $d64DiskDirObj = D64::Disk::Dir->new(); | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Create new C<D64::Disk::Dir> object and read entire D64/D71/D81 disk image directory from file on disk for further access. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | my $d64DiskDirObj = D64::Disk::Dir->new($filename); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | A valid C<D64::Disk::Dir> object is returned upon success, an undefined value otherwise. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 35 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 35 | my $this = shift; | |||||||||||||||||||||||||||
| 100 | 35 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||
| 101 | 35 | my $self = {}; | |||||||||||||||||||||||||||
| 102 | 35 | bless $self, $class; | |||||||||||||||||||||||||||
| 103 | 35 | my $initOK = $self->_initialize(@_); | |||||||||||||||||||||||||||
| 104 | 35 | ▶ | if ($initOK) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 35 | return $self; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||
| 108 | 0 | return undef; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 35 | ▶ | sub _initialize { | ||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 113 | 35 | my $self = shift; | |||||||||||||||||||||||||||
| 114 | 35 | my $filename = shift; | |||||||||||||||||||||||||||
| 115 | # Read entire disk image directory: | ||||||||||||||||||||||||||||
| 116 | 35 | ▶ | if (defined $filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 33 | my $readOK = $self->read_dir($filename); | |||||||||||||||||||||||||||
| 118 | 33 | ▶ | return 0 unless $readOK; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 35 | return 1; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 114 | ▶ | sub _check_dir_read { | ||||||||||||||||||||||||||
|
Subroutine
_check_dir_read: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 124 | 114 | my $self = shift; | |||||||||||||||||||||||||||
| 125 | # Raise error if directory has not been read yet: | ||||||||||||||||||||||||||||
| 126 | 114 | ▶ | croak "Unable to perform requested operation, because disk image directory has not been read yet" if $self->{'DIR_READ'} == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 34 | ▶ | sub _init_dir { | ||||||||||||||||||||||||||
|
Subroutine
_init_dir: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 130 | 34 | my $self = shift; | |||||||||||||||||||||||||||
| 131 | # Directory has not been read yet: | ||||||||||||||||||||||||||||
| 132 | 34 | $self->{'DIR_READ'} = 0; | |||||||||||||||||||||||||||
| 133 | 34 | $self->_release_d64_image(); | |||||||||||||||||||||||||||
| 134 | 34 | $self->_clear_dir_entries(); | |||||||||||||||||||||||||||
| 135 | 34 | delete $self->{'D64_FILE_NAME'}; | |||||||||||||||||||||||||||
| 136 | 34 | delete $self->{'DIR_INFO'}; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =head2 read_dir | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Read entire D64/D71/D81 disk image directory from file on disk, replacing currently loaded directory (if any). | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | $d64DiskDirObj->read_dir($filename); | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | Returns true value upon success, and false otherwise. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =cut | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 34 | ▶ | sub read_dir { | ||||||||||||||||||||||||||
|
Subroutine
read_dir: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 150 | 34 | my $self = shift; | |||||||||||||||||||||||||||
| 151 | 34 | my $filename = shift; | |||||||||||||||||||||||||||
| 152 | # We do not verify file existence here, D64::Disk::Image module croaks on inexisting files: | ||||||||||||||||||||||||||||
| 153 | 34 | $self->_init_dir(); | |||||||||||||||||||||||||||
| 154 | # Load image into RAM: | ||||||||||||||||||||||||||||
| 155 | 34 | my $d64DiskImageObj = D64::Disk::Image->load_image($filename); | |||||||||||||||||||||||||||
| 156 | 34 | $self->{'D64_DISK_IMAGE'} = $d64DiskImageObj; | |||||||||||||||||||||||||||
| 157 | 34 | $self->{'D64_FILE_NAME'} = $filename; | |||||||||||||||||||||||||||
| 158 | # Open directory for reading: | ||||||||||||||||||||||||||||
| 159 | 34 | my $dir = $d64DiskImageObj->open('$', T_PRG, F_READ); | |||||||||||||||||||||||||||
| 160 | # Get disk-wide directory information: | ||||||||||||||||||||||||||||
| 161 | 34 | $self->_get_dir_info($dir); | |||||||||||||||||||||||||||
| 162 | # Read directory blocks: | ||||||||||||||||||||||||||||
| 163 | 34 | my $readOK = $self->_read_dir_blocks($dir); | |||||||||||||||||||||||||||
| 164 | 34 | ▶ | return 0 unless $readOK; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | # Close directory: | ||||||||||||||||||||||||||||
| 166 | 34 | $dir->close(); | |||||||||||||||||||||||||||
| 167 | # Store D64 disk image filename for further checks: | ||||||||||||||||||||||||||||
| 168 | 34 | $self->{'FILENAME'} = $filename; | |||||||||||||||||||||||||||
| 169 | # Directory has been read successfully: | ||||||||||||||||||||||||||||
| 170 | 34 | $self->{'DIR_READ'} = 1; | |||||||||||||||||||||||||||
| 171 | 34 | return 1; | |||||||||||||||||||||||||||
| 172 | # There was a problem reading directory: | ||||||||||||||||||||||||||||
| 173 | 0 | return 0; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 34 | ▶ | sub _read_dir_blocks { | ||||||||||||||||||||||||||
|
Subroutine
_read_dir_blocks: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||
| 177 | 34 | my $self = shift; | |||||||||||||||||||||||||||
| 178 | 34 | my $dir = shift; | |||||||||||||||||||||||||||
| 179 | # Read first block into buffer: | ||||||||||||||||||||||||||||
| 180 | 34 | my ($counter, $buffer) = $dir->read(254); | |||||||||||||||||||||||||||
| 181 | 34 | ▶ | if ($counter != 254) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | carp 'BAM read failed'; | |||||||||||||||||||||||||||
| 183 | 0 | return 0; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | # Read directory blocks: | ||||||||||||||||||||||||||||
| 186 | 34 | while (1) { | |||||||||||||||||||||||||||
| 187 | 68 | my ($counter, $buffer) = $dir->read(254); | |||||||||||||||||||||||||||
| 188 | 68 | ▶ | last unless $counter == 254; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 34 | ▶ | for (my $offset = -2; $offset < 254; $offset += 32) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | # If file type != 0: | ||||||||||||||||||||||||||||
| 191 | 272 | my $file_type = ord (substr $buffer, $offset + 2, 1); | |||||||||||||||||||||||||||
| 192 | 272 | ▶ | if ($file_type != 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | # Create new D64::Disk::Dir::Entry object: | ||||||||||||||||||||||||||||
| 194 | 102 | my $bytes = substr $buffer, $offset + 2, 30; | |||||||||||||||||||||||||||
| 195 | 102 | my $entryObj = D64::Disk::Dir::Entry->new($bytes); | |||||||||||||||||||||||||||
| 196 | 102 | ▶ | unless (defined $entryObj) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | carp 'Directory blocks read failed'; | |||||||||||||||||||||||||||
| 198 | 0 | return 0; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | # Add it to the list of directory entries: | ||||||||||||||||||||||||||||
| 201 | 102 | $self->_add_dir_entry($entryObj); | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | 34 | return 1; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 34 | ▶ | sub _get_dir_info { | ||||||||||||||||||||||||||
|
Subroutine
_get_dir_info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 209 | 34 | my $self = shift; | |||||||||||||||||||||||||||
| 210 | 34 | my $dir = shift; | |||||||||||||||||||||||||||
| 211 | 34 | my $d64DiskImageObj = $self->{'D64_DISK_IMAGE'}; | |||||||||||||||||||||||||||
| 212 | # Get number of blocks free: | ||||||||||||||||||||||||||||
| 213 | 34 | my $blocksFree = $d64DiskImageObj->blocksfree(); | |||||||||||||||||||||||||||
| 214 | # Get title and ID: | ||||||||||||||||||||||||||||
| 215 | 34 | my ($title, $id) = $d64DiskImageObj->title(); | |||||||||||||||||||||||||||
| 216 | 34 | $title = D64::Disk::Image->name_from_rawname($title); | |||||||||||||||||||||||||||
| 217 | # Store directory details in a hash: | ||||||||||||||||||||||||||||
| 218 | 34 | $self->{'DIR_INFO'} = { | |||||||||||||||||||||||||||
| 219 | 'TITLE' => $title, | ||||||||||||||||||||||||||||
| 220 | 'ID' => $id, | ||||||||||||||||||||||||||||
| 221 | 'BLOCKS_FREE' => $blocksFree, | ||||||||||||||||||||||||||||
| 222 | }; | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 102 | ▶ | sub _add_dir_entry { | ||||||||||||||||||||||||||
|
Subroutine
_add_dir_entry: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 226 | 102 | my $self = shift; | |||||||||||||||||||||||||||
| 227 | 102 | my $entryObj = shift; | |||||||||||||||||||||||||||
| 228 | 102 | push @{$self->{'DIR_ENTRIES'}}, $entryObj; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 90 | ▶ | sub _get_dir_entries { | ||||||||||||||||||||||||||
|
Subroutine
_get_dir_entries: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 232 | 90 | my $self = shift; | |||||||||||||||||||||||||||
| 233 | 90 | my $entries = $self->{'DIR_ENTRIES'}; | |||||||||||||||||||||||||||
| 234 | 90 | ▶ | $entries = [] unless defined $entries; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 90 | return $entries; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 34 | ▶ | sub _clear_dir_entries { | ||||||||||||||||||||||||||
|
Subroutine
_clear_dir_entries: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 239 | 34 | my $self = shift; | |||||||||||||||||||||||||||
| 240 | 34 | $self->{'DIR_ENTRIES'} = []; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =head2 get_title | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | Get 16 character disk directory title (PETSCII string): | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | my $convert2ascii = 0; | ||||||||||||||||||||||||||||
| 248 | my $title = $d64DiskDirObj->get_title($convert2ascii); | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | Get disk directory title converted to ASCII string: | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | my $convert2ascii = 1; | ||||||||||||||||||||||||||||
| 253 | my $title = $d64DiskDirObj->get_title($convert2ascii); | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | =cut | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 5 | ▶ | sub get_title { | ||||||||||||||||||||||||||
|
Subroutine
get_title: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 258 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 259 | 5 | my $convert2ascii = shift; | |||||||||||||||||||||||||||
| 260 | 5 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 261 | 5 | my $title = $self->{'DIR_INFO'}->{'TITLE'}; | |||||||||||||||||||||||||||
| 262 | # Convert title to ASCII when necessary: | ||||||||||||||||||||||||||||
| 263 | 5 | ▶ | $title = D64::Disk::Image->petscii_to_ascii($title) if $convert2ascii; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 5 | return $title; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =head2 get_id | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | Get 5 character disk directory ID (PETSCII string): | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | my $convert2ascii = 0; | ||||||||||||||||||||||||||||
| 272 | my $diskID = $d64DiskDirObj->get_id($convert2ascii); | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Get disk directory ID converted to ASCII string: | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | my $convert2ascii = 1; | ||||||||||||||||||||||||||||
| 277 | my $diskID = $d64DiskDirObj->get_id($convert2ascii); | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =cut | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 5 | ▶ | sub get_id { | ||||||||||||||||||||||||||
|
Subroutine
get_id: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 282 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 283 | 5 | my $convert2ascii = shift; | |||||||||||||||||||||||||||
| 284 | 5 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 285 | 5 | my $id = $self->{'DIR_INFO'}->{'ID'}; | |||||||||||||||||||||||||||
| 286 | # Convert disk ID to ASCII when necessary: | ||||||||||||||||||||||||||||
| 287 | 5 | ▶ | $id = D64::Disk::Image->petscii_to_ascii($id) if $convert2ascii; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 5 | return $id; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =head2 get_blocks_free | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | Get number of blocks free: | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | my $blocksFree = $d64DiskDirObj->get_blocks_free(); | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =cut | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 5 | ▶ | sub get_blocks_free { | ||||||||||||||||||||||||||
|
Subroutine
get_blocks_free: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 300 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 301 | 5 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 302 | 5 | my $blocksFree = $self->{'DIR_INFO'}->{'BLOCKS_FREE'}; | |||||||||||||||||||||||||||
| 303 | 5 | return $blocksFree; | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | =head2 num_entries | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | Get number of directory entries: | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | my $num_entries = $d64DiskDirObj->num_entries(); | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 46 | ▶ | sub num_entries { | ||||||||||||||||||||||||||
|
Subroutine
num_entries: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 315 | 46 | my $self = shift; | |||||||||||||||||||||||||||
| 316 | 46 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 317 | 46 | my $entries_aref = $self->_get_dir_entries(); | |||||||||||||||||||||||||||
| 318 | 46 | my $num_entries = @{$entries_aref}; | |||||||||||||||||||||||||||
| 319 | 46 | return $num_entries; | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | =head2 get_entry | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | Get directory entry at the specified position (index value must be a valid position equal or greater than 0 and less than number of directory entries): | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | my $entryObj = $d64DiskDirObj->get_entry($index); | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | Returns a valid L<D64::Disk::Dir::Entry> object upon success, and false otherwise. | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | =cut | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 41 | ▶ | sub get_entry { | ||||||||||||||||||||||||||
|
Subroutine
get_entry: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 333 | 41 | my $self = shift; | |||||||||||||||||||||||||||
| 334 | 41 | my $index = shift; | |||||||||||||||||||||||||||
| 335 | 41 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 336 | 41 | my $num_entries = $self->num_entries(); | |||||||||||||||||||||||||||
| 337 | 41 | ▶ | if ($index < 0 or $index >= $num_entries) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index < 0 or $index >= $num_entries
MC/DC0%0/2
$index < 0 or $index >= $num_entries
$index < 0
$index >= $num_entries
Truth table33%1/3
A or B
A= $index < 0B= $index >= $num_entries
| |||||||||||||||||||||||||||||
| 338 | 0 | carp "Cannot get entry at invalid index position (disk directory contains only ${num_entries} file(s), unable to get entry at position ${index})"; | |||||||||||||||||||||||||||
| 339 | 0 | return undef; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | 41 | my $entries_aref = $self->_get_dir_entries(); | |||||||||||||||||||||||||||
| 342 | 41 | my $entryObj = $entries_aref->[$index]; | |||||||||||||||||||||||||||
| 343 | 41 | return $entryObj; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head2 get_file_data | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | Get binary file data from a directory entry at the specified position: | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | my $data = $d64DiskDirObj->get_file_data($index); | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | Reads data from a file at the specified directory index position (index value must be a valid position equal or greater than 0 and less than number of directory entries). Returns binary file data (including its loading address) upon success, and an undefined value otherwise. | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | =cut | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 8 | ▶ | sub get_file_data { | ||||||||||||||||||||||||||
|
Subroutine
get_file_data: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||
| 357 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 358 | 8 | my $index = shift; | |||||||||||||||||||||||||||
| 359 | 8 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 360 | 8 | my $entryObj = $self->get_entry($index); | |||||||||||||||||||||||||||
| 361 | 8 | ▶ | unless (defined $entryObj) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 0 | carp "Unable to get file data from an inexisting directory entry (validate first that ${index} file(s) really exist(s) on this disk!)"; | |||||||||||||||||||||||||||
| 363 | 0 | return undef; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | 8 | my $d64DiskImageObj = $self->{'D64_DISK_IMAGE'}; | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | # Validate initial track/sector: | ||||||||||||||||||||||||||||
| 368 | 8 | my $track = $entryObj->get_track(); | |||||||||||||||||||||||||||
| 369 | 8 | my $sector = $entryObj->get_sector(); | |||||||||||||||||||||||||||
| 370 | 8 | my $imageType = $d64DiskImageObj->type(); | |||||||||||||||||||||||||||
| 371 | 8 | my $tracks = $d64DiskImageObj->tracks($imageType); | |||||||||||||||||||||||||||
| 372 | 8 | ▶ | if ($track < 1 || $track > $tracks) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$track < 1 or $track > $tracks
MC/DC50%1/2
$track < 1 or $track > $tracks
$track < 1
$track > $tracks
Truth table66%2/3
A or B
A= $track < 1B= $track > $tracks
| |||||||||||||||||||||||||||||
| 373 | 1 | carp "Unable to get file data from an illegal track (validate first that initial track ${track} really exists on this disk!)"; | |||||||||||||||||||||||||||
| 374 | 1 | return undef; | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | 7 | my $sectors_per_track = $d64DiskImageObj->sectors_per_track($imageType, $track); | |||||||||||||||||||||||||||
| 377 | 7 | ▶ | if ($sector < 0 || $sector >= $sectors_per_track) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sector < 0 or $sector >= $sectors_per_track
MC/DC50%1/2
$sector < 0 or $sector >= $sectors_per_track
$sector < 0
$sector >= $sectors_per_track
Truth table66%2/3
A or B
A= $sector < 0B= $sector >= $sectors_per_track
| |||||||||||||||||||||||||||||
| 378 | 1 | carp "Unable to get file data from an illegal sector (validate first that initial sector ${sector} really exists on track ${track}!)"; | |||||||||||||||||||||||||||
| 379 | 1 | return undef; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | # Get filename from the specified directory index position: | ||||||||||||||||||||||||||||
| 383 | 6 | my $name = $entryObj->get_name(0); | |||||||||||||||||||||||||||
| 384 | 6 | my $rawname = D64::Disk::Image->rawname_from_name($name); | |||||||||||||||||||||||||||
| 385 | # Get the actual filetype: | ||||||||||||||||||||||||||||
| 386 | 6 | my $type = $entryObj->get_type(); | |||||||||||||||||||||||||||
| 387 | 6 | my $filetype = $file_type_constants{$type}; | |||||||||||||||||||||||||||
| 388 | # Open a file for reading: | ||||||||||||||||||||||||||||
| 389 | 6 | my $prg = $d64DiskImageObj->open($rawname, $filetype, F_READ); | |||||||||||||||||||||||||||
| 390 | # Read data from file: | ||||||||||||||||||||||||||||
| 391 | 6 | my ($counter, $buffer) = $prg->read(); | |||||||||||||||||||||||||||
| 392 | # Close a file: | ||||||||||||||||||||||||||||
| 393 | 6 | $prg->close(); | |||||||||||||||||||||||||||
| 394 | 6 | return $buffer; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | =head2 print_dir | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | Print out the entire directory content to any opened file handle (the standard output by default): | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | $d64DiskDirObj->print_dir($fh, { verbose => $verbose }); | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | C<verbose> defaults to false (changing it to true will additionally print out all files' track, sector, and loading address values). | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 4 | ▶ | sub print_dir { | ||||||||||||||||||||||||||
|
Subroutine
print_dir: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 408 | 4 | my ($self, $fh, $args) = @_; | |||||||||||||||||||||||||||
| 409 | 4 | ▶ | $fh = *STDOUT unless defined $fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 4 | ▶ | $args = {} unless defined $args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 4 | my $verbose = $args->{verbose}; | |||||||||||||||||||||||||||
| 412 | 4 | $self->_check_dir_read(); | |||||||||||||||||||||||||||
| 413 | 4 | $self->_print_title($fh); | |||||||||||||||||||||||||||
| 414 | 4 | my $num_entries = $self->num_entries(); | |||||||||||||||||||||||||||
| 415 | 4 | ▶ | for (my $i = 0; $i < $num_entries; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | 12 | my $entryObj = $self->get_entry($i); | |||||||||||||||||||||||||||
| 417 | # Set up the loading address: | ||||||||||||||||||||||||||||
| 418 | 12 | my $loading_address = ''; | |||||||||||||||||||||||||||
| 419 | 12 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 420 | # Get the actual file type: | ||||||||||||||||||||||||||||
| 421 | 6 | my $type = $entryObj->get_type(); | |||||||||||||||||||||||||||
| 422 | 6 | my $filetype = $file_type_constants{$type}; | |||||||||||||||||||||||||||
| 423 | # Read the file data only for PRG files: | ||||||||||||||||||||||||||||
| 424 | 6 | ▶ | if ($filetype == T_PRG) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | # Do not attempt to read loading address of a non-closed file: | ||||||||||||||||||||||||||||
| 426 | 6 | ▶ | if ($entryObj->get_closed()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | # Compute the loading address: | ||||||||||||||||||||||||||||
| 428 | 5 | my $data = $self->get_file_data($i); | |||||||||||||||||||||||||||
| 429 | 5 | ▶ | if ($data) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 430 | 5 | my ($lo, $hi) = map { ord } split //, substr $data, 0, 2; | |||||||||||||||||||||||||||
| 431 | 5 | $loading_address = sprintf ' $%04x', $lo + $hi * 256; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | 12 | my $print_fh = new IO::Scalar; | |||||||||||||||||||||||||||
| 437 | 12 | $entryObj->print_entry($print_fh, { verbose => $verbose }); | |||||||||||||||||||||||||||
| 438 | 12 | my $entry_content = ${$print_fh->sref}; | |||||||||||||||||||||||||||
| 439 | # Append the loading address to printed entry: | ||||||||||||||||||||||||||||
| 440 | 12 | chomp $entry_content; | |||||||||||||||||||||||||||
| 441 | 12 | $entry_content .= $loading_address . "\n"; | |||||||||||||||||||||||||||
| 442 | # Print entry to $fh: | ||||||||||||||||||||||||||||
| 443 | 12 | print $fh $entry_content; | |||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | 4 | $self->_print_blocks_free($fh); | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | 4 | ▶ | sub _print_title { | ||||||||||||||||||||||||||
|
Subroutine
_print_title: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 449 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 450 | 4 | my $fh = shift; | |||||||||||||||||||||||||||
| 451 | # Get title converted to ASCII: | ||||||||||||||||||||||||||||
| 452 | 4 | my $title = $self->get_title(1); | |||||||||||||||||||||||||||
| 453 | # Get disk ID converted to ASCII: | ||||||||||||||||||||||||||||
| 454 | 4 | my $id = $self->get_id(1); | |||||||||||||||||||||||||||
| 455 | # Print title and disk ID: | ||||||||||||||||||||||||||||
| 456 | 4 | print $fh '0 '; | |||||||||||||||||||||||||||
| 457 | 4 | my $header_text = sprintf "\"%-16s\" %-5s", $title, $id; | |||||||||||||||||||||||||||
| 458 | 4 | print $fh REVERSE, $header_text, RESET; | |||||||||||||||||||||||||||
| 459 | 4 | print $fh "\n"; | |||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | 4 | ▶ | sub _print_blocks_free { | ||||||||||||||||||||||||||
|
Subroutine
_print_blocks_free: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 463 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 464 | 4 | my $fh = shift; | |||||||||||||||||||||||||||
| 465 | # Print number of blocks free: | ||||||||||||||||||||||||||||
| 466 | 4 | my $blocksFree = $self->get_blocks_free(); | |||||||||||||||||||||||||||
| 467 | 4 | printf $fh "%d blocks free\n", $blocksFree; | |||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 35 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 471 | 35 | my $self = shift; | |||||||||||||||||||||||||||
| 472 | 35 | $self->_release_d64_image(); | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 69 | ▶ | sub _release_d64_image { | ||||||||||||||||||||||||||
|
Subroutine
_release_d64_image: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 476 | 69 | my $self = shift; | |||||||||||||||||||||||||||
| 477 | 69 | my $d64DiskImageObj = $self->{'D64_DISK_IMAGE'}; | |||||||||||||||||||||||||||
| 478 | 69 | delete $self->{'D64_DISK_IMAGE'}; | |||||||||||||||||||||||||||
| 479 | # Release D64 image: | ||||||||||||||||||||||||||||
| 480 | 69 | ▶ | $d64DiskImageObj->free_image() if defined $d64DiskImageObj; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =head1 BUGS | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | There are no known bugs at the moment. Please report any bugs or feature requests. | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =head1 EXPORT | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | None. No method is exported into the caller's namespace either by default or explicitly. | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | L<D64::Disk::Dir::Entry>, L<D64::Disk::Dir::Iterator>, L<D64::Disk::Image> | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | Pawel Krol, E<lt>pawelkrol@cpan.orgE<gt>. | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =head1 VERSION | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | Version 0.06 (2023-08-28) | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | This module is licensed under a slightly modified BSD license, the same terms as Per Olofsson's "diskimage.c" library and L<D64::Disk::Image> Perl package it is based on, license contents are repeated below. | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | Copyright (c) 2003-2006, Per Olofsson | ||||||||||||||||||||||||||||
| 508 | All rights reserved. | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | =over | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | =item * | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | =item * | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 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. | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | =back | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 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. | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | diskimage.c website: L<https://paradroid.automac.se/diskimage/> | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =cut | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 4 | 1; | |||||||||||||||||||||||||||