Mercurial > hg > dmlib
changeset 2602:a4f6584edca9
Hopefully improve the use-cases for 64vw "-l" option by also listing
files that are not recognized.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 19 Nov 2023 20:02:03 +0200 |
parents | 8b99ddcc9fde |
children | 8386c5e55a31 |
files | tools/64vw.c tools/lib64util.c |
diffstat | 2 files changed, 28 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/64vw.c Sun Nov 19 15:43:31 2023 +0200 +++ b/tools/64vw.c Sun Nov 19 20:02:03 2023 +0200 @@ -43,7 +43,7 @@ { 14, 'f', "format" , "Force input format (see --formats)", OPT_ARGREQ }, { 16, 'F', "formats" , "List supported input formats", OPT_NONE }, { 18, 'i', "info" , "Print information only (no display)", OPT_NONE }, - { 20, 'l', "list" , "List files that were recognized (implies -i)", OPT_NONE }, + { 20, 'l', "list" , "One line per file list of detected format", OPT_NONE }, { 22, 'P', "probe" , "Probe only (do not attempt to decode the image)", OPT_NONE }, { 24, 0, "char-rom" , "Set character ROM file to be used.", OPT_ARGREQ }, { 26, 'p', "palette" , "Set C64 palette to be used (see -p list).", OPT_ARGREQ }, @@ -335,24 +335,35 @@ const DMC64ImageFormat *fmt = NULL; DMC64Image *cimage = NULL; - if ((res = dmReadC64Image(filename, forced, &fmt, &cimage)) != DMERR_OK) + res = dmReadC64Image(filename, forced, &fmt, &cimage); + if (optListOnly) { - if (!optListOnly && res != DMERR_NOT_SUPPORTED) + fprintf(stdout, "%s | ", filename); + if (res == DMERR_OK || res == DMERR_NOT_SUPPORTED) + { + fprintf(stdout, "%s [%s]\n", + fmt != NULL ? fmt->name : "UNKNOWN", + fmt != NULL ? fmt->fext : "???"); + } + else + { + fprintf(stdout, "ERROR: %s\n", + dmErrorStr(res)); + } + } + else + { + fprintf(stdout, "\n%s\n", filename); + if (res == DMERR_OK || res == DMERR_NOT_SUPPORTED) + { + dmC64ImageDump(stdout, cimage, fmt, " "); + } + else { dmErrorMsg("Could not decode file '%s': %s\n", filename, dmErrorStr(res)); } } - else - if (optListOnly) - { - fprintf(stdout, "%s\n", filename); - } - else - { - fprintf(stdout, "\n%s\n", filename); - dmC64ImageDump(stdout, cimage, fmt, " "); - } dmC64ImageFree(cimage); }
--- a/tools/lib64util.c Sun Nov 19 15:43:31 2023 +0200 +++ b/tools/lib64util.c Sun Nov 19 20:02:03 2023 +0200 @@ -133,12 +133,10 @@ { char typeStr[64]; - if (fmt != NULL) - { - dmC64ImageDumpLine(fh, indent, - "Format", "%s [%s]", - fmt->name, fmt->fext); - } + dmC64ImageDumpLine(fh, indent, + "Format", "%s [%s]", + fmt != NULL ? fmt->name : "UNKNOWN", + fmt != NULL ? fmt->fext : "???"); if (img != NULL) {