# HG changeset patch # User Matti Hamalainen # Date 1700416923 -7200 # Node ID a4f6584edca9d7487b1cc5ec2c00b4650bdad3d8 # Parent 8b99ddcc9fdebdf70a67b9920fa547f898927d6c Hopefully improve the use-cases for 64vw "-l" option by also listing files that are not recognized. diff -r 8b99ddcc9fde -r a4f6584edca9 tools/64vw.c --- 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); } diff -r 8b99ddcc9fde -r a4f6584edca9 tools/lib64util.c --- 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) {