diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extract.c | 6 | ||||
| -rw-r--r-- | src/io.c | 5 | ||||
| -rw-r--r-- | src/unalf.h | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/extract.c b/src/extract.c index aa7f75b..0fb61f4 100644 --- a/src/extract.c +++ b/src/extract.c @@ -3,6 +3,7 @@ int bad_checksum, bad_checksum_count = 0; int new_file = 0; +unsigned int bytes_written = 0; char *out_filename; void dpoke(int addr, u16 value) { @@ -153,10 +154,13 @@ void extract_alf(void) { out_filename = realname; } - bad_checksum = 0; + bad_checksum = bytes_written = 0; new_file = 1; uncrunch_file(); if(bad_checksum) bad_checksum_count++; + if(bytes_written != getquad(alf_hdr_origsize0)) + fprintf(stderr, "%s: %s should be %u bytes, but extracted to %u.\n", + self, out_filename, getquad(alf_hdr_origsize0), bytes_written); if(!opts.extract_to_stdout) fclose(out_file); out_filename = 0; @@ -142,5 +142,10 @@ void writeblock(void) { // fprintf(stderr, "writeblock, bufadr = $%04x, len = $%04x\n", bufadr, len); bytes = fwrite(buf, 1, len, out_file); + if(bytes < 0) { + perror(self); /* TODO: out_filename */ + exit(1); + } + bytes_written += bytes; dpoke(buf_len_l, bytes); } diff --git a/src/unalf.h b/src/unalf.h index 3c461ef..6096101 100644 --- a/src/unalf.h +++ b/src/unalf.h @@ -55,6 +55,7 @@ unsigned int getquad(int offs); /* extract.c */ extern int bad_checksum_count; extern int new_file; +extern unsigned int bytes_written; void extract_alf(void); void dpoke(int addr, u16 value); u16 dpeek(int addr); |
