mirror of
https://github.com/softwarejanitor/ProDOS.git
synced 2024-05-29 02:41:31 +00:00
Work on writing files
This commit is contained in:
parent
83b056bb8c
commit
e7fd625bd5
44
ProDOS.pm
44
ProDOS.pm
|
@ -1662,15 +1662,47 @@ sub write_file {
|
||||||
# Sapling file.
|
# Sapling file.
|
||||||
$file_storage_type = 0x20;
|
$file_storage_type = 0x20;
|
||||||
|
|
||||||
# Write out the index block.
|
# Get a block off the free blocks list for the index block.
|
||||||
##FIXME
|
my $blknum = pop @free_blocks;
|
||||||
|
$key_pointer = $blknum;
|
||||||
|
|
||||||
|
# Data for index block.
|
||||||
|
my @indbytes = ();
|
||||||
|
|
||||||
# Add index block to used blocks
|
# Add index block to used blocks
|
||||||
##FIXME
|
push @used_blocks, $blknum;
|
||||||
|
|
||||||
# Write out the data blocks.
|
# Write out the data blocks.
|
||||||
##FIXME
|
for (my $blk = 0; $blk < $numblocks; $blk++) {
|
||||||
# Add each block to used blocks list.
|
# Get a free block.
|
||||||
##FIXME
|
my $datablknum = pop @free_blocks;
|
||||||
|
|
||||||
|
# Get the data for this block
|
||||||
|
my @databytes = splice @bytes, 0, 512;
|
||||||
|
|
||||||
|
# Pack the data.
|
||||||
|
my $databuf = pack "C*", @databytes;
|
||||||
|
|
||||||
|
# Write out the block
|
||||||
|
if (!write_blk($pofile, $datablknum, \$databuf)) {
|
||||||
|
print "I/O Error writeing block $datablknum\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add each block to used blocks list.
|
||||||
|
push @used_blocks, $datablknum;
|
||||||
|
|
||||||
|
# Add block to index block
|
||||||
|
$indbytes[$blk] = $datablknum & 0xff00; # LO byte
|
||||||
|
$indbytes[$blk + 256] = $datablknum >> 8; # HI byte
|
||||||
|
}
|
||||||
|
|
||||||
|
my $indbuf = pack "C*", @indbytes;
|
||||||
|
|
||||||
|
# Write out the index block.
|
||||||
|
if (!write_blk($pofile, $blknum, \$indbuf)) {
|
||||||
|
print "I/O Error writing block $blknum\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
# Tree file.
|
# Tree file.
|
||||||
$file_storage_type = 0x30;
|
$file_storage_type = 0x30;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user