From 960b70559681a55f1cd580f3b6516c2c6fdc0cba Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 1 Aug 2021 20:15:02 -0400 Subject: [PATCH] prodos: add support for tree files I only am testing on floppies so no files >128k to test --- utils/prodos-utils/prodos.c | 83 ++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/utils/prodos-utils/prodos.c b/utils/prodos-utils/prodos.c index 66e529a9..0de0f24f 100644 --- a/utils/prodos-utils/prodos.c +++ b/utils/prodos-utils/prodos.c @@ -12,7 +12,7 @@ #include "prodos.h" static int ignore_errors=0; -int debug=1; +int debug=0; /* Read volume directory into a buffer */ static int prodos_read_voldir(int fd, struct voldir_t *voldir, int interleave) { @@ -510,8 +510,8 @@ static int prodos_load_file(struct voldir_t *voldir, int output_fd; unsigned char data[PRODOS_BYTES_PER_BLOCK]; unsigned char index_block[PRODOS_BYTES_PER_BLOCK]; - unsigned char sector_buffer[PRODOS_BYTES_PER_BLOCK]; - int result,chunk,chunk_block; + unsigned char master_index_block[PRODOS_BYTES_PER_BLOCK]; + int result,chunk,chunk_block,index,blocks_left,read_blocks; struct file_entry_t file; /* FIXME! Warn if overwriting file! */ @@ -547,7 +547,9 @@ static int prodos_load_file(struct voldir_t *voldir, break; case PRODOS_FILE_SAPLING: - /* Just a single block */ + /* Index block points to up to 256 blocks */ + /* Addresses are stored low-byte (256 bytes) then hi-byte */ + /* Address of zero means file hole, all zeros */ if (debug) fprintf(stderr,"Loading index " "block $%x\n", file.key_pointer); @@ -560,12 +562,19 @@ static int prodos_load_file(struct voldir_t *voldir, for(chunk=0;chunk