From 79a302f4f8d6ab7047b88f66d0c7583e3cb0c332 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Tue, 29 Mar 2022 20:18:47 -0700 Subject: [PATCH] Some archives don't have DIZ in the root directory (I'm looking at you, mist1221.zip) ... so first try to extract DIZ files from the root of the archive, then try again searching nested directories too. <sigh> --- src/sbbs3/filedat.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/sbbs3/filedat.c b/src/sbbs3/filedat.c index ae598427c2..23acf53934 100644 --- a/src/sbbs3/filedat.c +++ b/src/sbbs3/filedat.c @@ -1027,20 +1027,23 @@ bool extract_diz(scfg_t* cfg, file_t* f, str_list_t diz_fnames, char* path, size return false; } - if(extract_files_from_archive(archive - ,/* outdir: */cfg->temp_dir - ,/* allowed_filename_chars: */NULL /* any */ - ,/* with_path: */true - ,/* overwrite: */false - ,/* max_files: */strListCount(diz_fnames) - ,/* file_list: */diz_fnames - ,/* error: */NULL, 0) >= 0) { - for(i = 0; diz_fnames[i] != NULL; i++) { - safe_snprintf(path, maxlen, "%s%s", cfg->temp_dir, diz_fnames[i]); // no slash - if(fexistcase(path)) - return true; + for(int nested = 0; nested <= 1; nested++) { + if(extract_files_from_archive(archive + ,/* outdir: */cfg->temp_dir + ,/* allowed_filename_chars: */NULL /* any */ + ,/* with_path: */!nested + ,/* overwrite: */false + ,/* max_files: */strListCount(diz_fnames) + ,/* file_list: */diz_fnames + ,/* error: */NULL, 0) >= 0) { + for(i = 0; diz_fnames[i] != NULL; i++) { + safe_snprintf(path, maxlen, "%s%s", cfg->temp_dir, diz_fnames[i]); // no slash + if(fexistcase(path)) + return true; + } + if(nested) + return false; } - return false; } char* fext = getfext(f->name); -- GitLab