From eefd3b26975c373798b954da4d3b0dde1bbfde2c Mon Sep 17 00:00:00 2001 From: Leeland Heins Date: Mon, 14 Jan 2019 13:23:59 -0600 Subject: [PATCH] Bug fixes --- ProDOS.pm | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- procat.pl | 34 +++++++++++++++++--------------- 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/ProDOS.pm b/ProDOS.pm index 7be4320..c2ba645 100644 --- a/ProDOS.pm +++ b/ProDOS.pm @@ -271,6 +271,9 @@ print"\n"; print sprintf("blocks_used=%04x\n", $blocks_used) if $debug; my $eof = shift @flds; #print sprintf("eof=%04x\n", $eof); + my ($e1, $e2, $e3) = unpack "C*", $eof; + my $endfile = (($e3 << 16) + ($e2 << 8) + $e1); + print sprintf("eof=%06x\n", $endfile) if $debug; my $creation_ymd = shift @flds; print sprintf("creation_ymd=%04x\n", $creation_ymd) if $debug; my $creation_hm = shift @flds; @@ -285,6 +288,10 @@ print"\n"; print sprintf("access=%02x\n", $access) if $debug; my $aux_type = shift @flds; print sprintf("aux_type=%02x\n", $aux_type) if $debug; + my $atype = ''; + if ($file_type == 0x06) { + $atype = sprintf("A=\$%04X", $aux_type); + } my $last_mod_ymd = shift @flds; print sprintf("last_mod_ymd=%04x\n", $last_mod_ymd) if $debug; my $last_mod_hm = shift @flds; @@ -294,7 +301,7 @@ print"\n"; print sprintf("header_pointer=%04x\n", $header_pointer) if $debug; if ($storage_type != 0) { #print "pushing $file_name\n"; - push @files, { 'filename' => $fname, 'ftype' => $ftype{$file_type}, 'used' => $blocks_used, 'mdate' => $mdate, 'cdate' => $cdate, 'atype' => $aux_type }; + push @files, { 'filename' => $fname, 'ftype' => $ftype{$file_type}, 'used' => $blocks_used, 'mdate' => $mdate, 'cdate' => $cdate, 'atype' => $aux_type, 'atype' => $atype, 'access' => $access, 'eof' => $endfile }; } } @@ -358,6 +365,9 @@ sub parse_vol_dir_blk { print sprintf("blocks_used=%04x\n", $blocks_used) if $debug; my $eof = shift @flds; #print sprintf("eof=%04x\n", $eof); + my ($e1, $e2, $e3) = unpack "C*", $eof; + my $endfile = (($e3 << 16) + ($e2 << 8) + $e1); + print sprintf("eof=%06x\n", $endfile) if $debug; my $creation_ymd = shift @flds; print sprintf("creation_ymd=%04x\n", $creation_ymd) if $debug; my $creation_hm = shift @flds; @@ -372,6 +382,10 @@ sub parse_vol_dir_blk { print sprintf("access=%02x\n", $access) if $debug; my $aux_type = shift @flds; print sprintf("aux_type=%02x\n", $aux_type) if $debug; + my $atype = ''; + if ($file_type == 0x06) { + $atype = sprintf("A=\$%04X", $aux_type); + } my $last_mod_ymd = shift @flds; print sprintf("last_mod_ymd=%04x\n", $last_mod_ymd) if $debug; my $last_mod_hm = shift @flds; @@ -381,7 +395,7 @@ sub parse_vol_dir_blk { print sprintf("header_pointer=%04x\n", $header_pointer) if $debug; if ($storage_type != 0) { #print "pushing $file_name\n"; - push @files, { 'filename' => $fname, 'ftype' => $ftype{$file_type}, 'used' => $blocks_used, 'mdate' => $mdate, 'cdate' => $cdate, 'atype' => $aux_type }; + push @files, { 'filename' => $fname, 'ftype' => $ftype{$file_type}, 'used' => $blocks_used, 'mdate' => $mdate, 'cdate' => $cdate, 'atype' => $aux_type, 'atype' => $atype, 'access' => $access, 'eof' => $endfile }; } } @@ -412,5 +426,45 @@ sub get_vol_dir_blk { return 0; } +# +# Get disk catalog. +# +sub cat { + my ($pofile, $dbg) = @_; + + $debug = 1 if defined $dbg && $dbg; + + my ($prv_vol_dir_blk, $nxt_vol_dir_blk, $storage_type_name_length, $volume_name, $creation_ymd, $creation_hm, $version, $min_version, $access, $entry_length, $entries_per_block, $file_count, $bit_map_pointer, $total_blocks, @files) = get_key_vol_dir_blk($pofile, $debug); + + print "/$volume_name\n\n"; + + print " NAME TYPE BLOCKS MODIFIED CREATED ENDFILE SUBTYPE\n\n"; + + foreach my $file (@files) { + my $lck = ' '; + #print printf("access=%02x\n", $file->{'access'}); + if ($file->{'access'} == 0x01) { + $lck = '*'; + } + print sprintf("%s%-15s %3s %7d %16s %16s %7s %s\n", $lck, $file->{'filename'}, $file->{'ftype'}, $file->{'used'}, $file->{'mdate'}, $file->{'cdate'}, $file->{'eof'}, $file->{'atype'}); + } + + my $vol_dir_blk = $nxt_vol_dir_blk; + + while ($vol_dir_blk) { + #my ($prv_vol_dir_blk, $nxt_vol_dir_blk, $storage_type_name_length, $volume_name, $creation_ymd, $creation_hm, $version, $min_version, $access, $entry_length, $entries_per_block, $file_count, $bit_map_pointer, $total_blocks, @files) = get_vol_dir_blk($pofile, $vol_dir_blk, $debug); + my ($prv_vol_dir_blk, $nxt_vol_dir_blk, @files) = get_vol_dir_blk($pofile, $vol_dir_blk, $debug); + foreach my $file (@files) { + my $lck = ' '; + #print printf("access=%02x\n", $file->{'access'}); + if ($file->{'access'} == 0x01) { + $lck = '*'; + } + print sprintf("%s%-15s %3s %7d %16s %16s %7s %s\n", $lck, $file->{'filename'}, $file->{'ftype'}, $file->{'used'}, $file->{'mdate'}, $file->{'cdate'}, $file->{'eof'}, $file->{'atype'}); + } + $vol_dir_blk = $nxt_vol_dir_blk; + } +} + 1; diff --git a/procat.pl b/procat.pl index f059735..d6010cc 100644 --- a/procat.pl +++ b/procat.pl @@ -21,7 +21,7 @@ while (defined $ARGV[0] && $ARGV[0] =~ /^-/) { my $pofile = shift or die "Must supply filename\n"; -my $buf; +#my $buf; #if (read_blk($pofile, $blk, \$buf)) { # dump_blk($buf); @@ -51,26 +51,28 @@ my $buf; #} -my ($prv_vol_dir_blk, $nxt_vol_dir_blk, $storage_type_name_length, $volume_name, $creation_ymd, $creation_hm, $version, $min_version, $access, $entry_length, $entries_per_block, $file_count, $bit_map_pointer, $total_blocks, @files) = get_key_vol_dir_blk($pofile, $debug); +#my ($prv_vol_dir_blk, $nxt_vol_dir_blk, $storage_type_name_length, $volume_name, $creation_ymd, $creation_hm, $version, $min_version, $access, $entry_length, $entries_per_block, $file_count, $bit_map_pointer, $total_blocks, @files) = get_key_vol_dir_blk($pofile, $debug); -print "/$volume_name\n\n"; +#print "/$volume_name\n\n"; -print "NAME TYPE BLOCKS MODIFIED CREATED ENDFILE SUBTYPE\n\n"; +#print " NAME TYPE BLOCKS MODIFIED CREATED ENDFILE SUBTYPE\n\n"; -foreach my $file (@files) { - print sprintf("%-15s %3s %7d %16s %16s\n", $file->{'filename'}, $file->{'ftype'}, $file->{'used'}, $file->{'mdate'}, $file->{'cdate'}); -} +#foreach my $file (@files) { +# print sprintf(" %-15s %3s %7d %16s %16s %7s %s\n", $file->{'filename'}, $file->{'ftype'}, $file->{'used'}, $file->{'mdate'}, $file->{'cdate'}, '', $file->{'atype'}); +#} -my $vol_dir_blk = $nxt_vol_dir_blk; +#my $vol_dir_blk = $nxt_vol_dir_blk; -while ($vol_dir_blk) { - #my ($prv_vol_dir_blk, $nxt_vol_dir_blk, $storage_type_name_length, $volume_name, $creation_ymd, $creation_hm, $version, $min_version, $access, $entry_length, $entries_per_block, $file_count, $bit_map_pointer, $total_blocks, @files) = get_vol_dir_blk($pofile, $vol_dir_blk, $debug); - my ($prv_vol_dir_blk, $nxt_vol_dir_blk, @files) = get_vol_dir_blk($pofile, $vol_dir_blk, $debug); - foreach my $file (@files) { - print sprintf("%-15s %3s %7d %16s %16s\n", $file->{'filename'}, $file->{'ftype'}, $file->{'used'}, $file->{'mdate'}, $file->{'cdate'}); - } - $vol_dir_blk = $nxt_vol_dir_blk; -} +#while ($vol_dir_blk) { +# #my ($prv_vol_dir_blk, $nxt_vol_dir_blk, $storage_type_name_length, $volume_name, $creation_ymd, $creation_hm, $version, $min_version, $access, $entry_length, $entries_per_block, $file_count, $bit_map_pointer, $total_blocks, @files) = get_vol_dir_blk($pofile, $vol_dir_blk, $debug); +# my ($prv_vol_dir_blk, $nxt_vol_dir_blk, @files) = get_vol_dir_blk($pofile, $vol_dir_blk, $debug); +# foreach my $file (@files) { +# print sprintf(" %-15s %3s %7d %16s %16s %7s %s\n", $file->{'filename'}, $file->{'ftype'}, $file->{'used'}, $file->{'mdate'}, $file->{'cdate'}, '', $file->{'atype'}); +# } +# $vol_dir_blk = $nxt_vol_dir_blk; +#} + +cat($pofile, $debug); 1;