From 67757c20c76156256b65dd8cdf6f30a29dc21937 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 11 Dec 2025 00:09:08 -0500 Subject: unalf: print out_filename in write failed error (e.g. disk full). --- src/io.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/io.c b/src/io.c index 2b76ab1..6f5027b 100644 --- a/src/io.c +++ b/src/io.c @@ -1,4 +1,3 @@ -// #include #include "unalf.h" #include "addrs.h" @@ -141,9 +140,9 @@ int read_alf_header(void) { } /* read buf_len_l/h bytes into buf_adr_l/h, then store the number - of bytes actually read in buf_len_l/h. TODO: what about EOF? */ + of bytes actually read in buf_len_l/h. EOF is handled like the + Atari does: you get a partial buffer *and* EOF status. */ void readblock(void) { - // static int bytes_read = 0; int bytes, len, bufadr; u8 *buf; @@ -152,9 +151,8 @@ void readblock(void) { len = dpeek(buf_len_l); bytes = fread(buf, 1, len, in_file); - // bytes_read += bytes; - /* mimic CIO's behaviour */ + /* mimic CIO's behaviour: Y=1 means OK, Y>=0x80 means error */ if(feof(in_file)) { ldy_i(0x88); } else { @@ -163,6 +161,7 @@ void readblock(void) { dpoke(buf_len_l, bytes); } +/* Atari-specific (can't use isprint()) */ static int is_printable(u8 c) { return (c == 0x9b || (c >= ' ' && c <= 124)); } @@ -200,14 +199,12 @@ void writeblock(void) { } } - // fprintf(stderr, "writeblock, bufadr = $%04x, len = $%04x\n", bufadr, len); - bytes = fwrite(buf, 1, len, out_file); if(bytes < 0) { + extern char *out_filename; /* extract.c */ fprintf(stderr, "%s: fatal: ", self); - perror("write failed"); /* TODO: out_filename */ + perror(out_filename); exit(1); } - bytes_written += bytes; dpoke(buf_len_l, bytes); } -- cgit v1.2.3