mirror of
https://github.com/softwarejanitor/ProDOS.git
synced 2024-06-01 06:41:28 +00:00
Work on delete & freeing sectors
This commit is contained in:
parent
0087238504
commit
c22e68e1b7
35
ProDOS.pm
35
ProDOS.pm
|
@ -1407,12 +1407,17 @@ sub write_vol_bit_map {
|
||||||
$num_vol_bit_map_blks = 1 if $num_vol_bit_map_blks < 1;
|
$num_vol_bit_map_blks = 1 if $num_vol_bit_map_blks < 1;
|
||||||
print sprintf("num_vol_bit_map_blks=%d\n", $num_vol_bit_map_blks);
|
print sprintf("num_vol_bit_map_blks=%d\n", $num_vol_bit_map_blks);
|
||||||
|
|
||||||
my $buf = pack $vol_bit_map_tmpl, @{$bitmaps};
|
# Handle multiple vol bit map blocks
|
||||||
|
for (my $vbmb = 0; $vbmb < $num_vol_bit_map_blks; $vbmb++) {
|
||||||
|
my @bytes = splice @{$bitmaps}, 0, 512;
|
||||||
|
|
||||||
|
my $buf = pack $vol_bit_map_tmpl, @bytes;
|
||||||
|
|
||||||
|
if (!write_blk($pofile, $bit_map_pointer + $vbmb, \$buf)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
##FIXME -- need to handle multiple vol bit map blocks here.
|
|
||||||
#if (!write_blk($pofile, $bit_map_pointer, \$buf)) {
|
|
||||||
# return 0;
|
|
||||||
#}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1597,6 +1602,8 @@ sub delete_file {
|
||||||
|
|
||||||
my $buf;
|
my $buf;
|
||||||
|
|
||||||
|
my $rv = 1;
|
||||||
|
|
||||||
if (read_blk($pofile, $header_pointer, \$buf)) {
|
if (read_blk($pofile, $header_pointer, \$buf)) {
|
||||||
dump_blk($buf) if $debug;
|
dump_blk($buf) if $debug;
|
||||||
#dump_blk($buf);
|
#dump_blk($buf);
|
||||||
|
@ -1625,7 +1632,7 @@ sub delete_file {
|
||||||
return free_blocks($pofile, \@blks, $debug);
|
return free_blocks($pofile, \@blks, $debug);
|
||||||
} elsif ($file_storage_type == 0x30) {
|
} elsif ($file_storage_type == 0x30) {
|
||||||
# Tree file.
|
# Tree file.
|
||||||
##FIXME
|
##TESTME
|
||||||
my $buf2;
|
my $buf2;
|
||||||
|
|
||||||
my @blks = get_master_ind_blk($pofile, $key_pointer, $debug);
|
my @blks = get_master_ind_blk($pofile, $key_pointer, $debug);
|
||||||
|
@ -1655,15 +1662,15 @@ sub delete_file {
|
||||||
last if $blkno++ == $blocks_used - 1;
|
last if $blkno++ == $blocks_used - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return free_blocks($pofile, \@blocks, $debug);
|
$rv = free_blocks($pofile, \@blocks, $debug);
|
||||||
} elsif ($file_storage_type == 0xd0) {
|
} elsif ($file_storage_type == 0xd0) {
|
||||||
# Subdirectory.
|
# Subdirectory.
|
||||||
##FIXME -- need to delete all blocks in the subdirectory.
|
##FIXME -- need to delete all blocks in the subdirectory.
|
||||||
return free_blocks($pofile, [ $key_pointer ], $debug);
|
$rv = free_blocks($pofile, [ $key_pointer ], $debug);
|
||||||
} elsif ($file_storage_type == 0xe0) {
|
} elsif ($file_storage_type == 0xe0) {
|
||||||
# Subdirectory Header.
|
# Subdirectory Header.
|
||||||
##FIXME
|
##FIXME
|
||||||
return free_blocks($pofile, [ $key_pointer ], $debug);
|
$rv = free_blocks($pofile, [ $key_pointer ], $debug);
|
||||||
} elsif ($file_storage_type == 0xf0) {
|
} elsif ($file_storage_type == 0xf0) {
|
||||||
# Volume directory Header. This should never happen.
|
# Volume directory Header. This should never happen.
|
||||||
printf("Can't delete volume directory header \$%02x\n", $header_pointer);
|
printf("Can't delete volume directory header \$%02x\n", $header_pointer);
|
||||||
|
@ -1684,17 +1691,15 @@ sub delete_file {
|
||||||
|
|
||||||
dump_blk($buf) if $debug;
|
dump_blk($buf) if $debug;
|
||||||
|
|
||||||
##FIXME
|
|
||||||
# Write the directory back out.
|
# Write the directory back out.
|
||||||
#if (!write_blk($pofile, $header_pointer, \$buf)) {
|
if (!write_blk($pofile, $header_pointer, \$buf)) {
|
||||||
# return 0;
|
return 0;
|
||||||
#} else {
|
}
|
||||||
#}
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return $rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user