diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-12-11 00:09:08 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-12-11 00:09:08 -0500 |
| commit | 67757c20c76156256b65dd8cdf6f30a29dc21937 (patch) | |
| tree | 41767a074f502398231ae18a671dfb7d276b9491 | |
| parent | 9428a7317ba4d6ea1e133181448714464c50792a (diff) | |
| download | alftools-67757c20c76156256b65dd8cdf6f30a29dc21937.tar.gz | |
unalf: print out_filename in write failed error (e.g. disk full).
| -rw-r--r-- | src/io.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -1,4 +1,3 @@ -// #include <f65.h> #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); } |
