From f7ed6f47deb97dee53b0f4f1f0c7b030bf87e3f9 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 13 Oct 2012 14:53:26 +0000 Subject: [PATCH] Prevent Windows "case mismatch" spam when loading files from disk with the Windows Explorer "hide extensions for known file types" option enabled. This simply changes the relevant Bstrcmp() calls to Bstrncmp() calls instead, using the length of the string returned by SHGetFileInfo() as the number of bytes to compare. git-svn-id: https://svn.eduke32.com/eduke32@3068 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/cache1d.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index fa375f0e8..fb970959d 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -681,18 +681,21 @@ int32_t (*check_filename_casing_fn)(void) = NULL; static int32_t check_filename_mismatch(const char *filename, int32_t ofs) { const char *fn = filename+ofs; + int32_t len; // we assume that UNICODE is not #defined, winlayer.c errors out else if (!SHGetFileInfo(filename, -1, &shinf, sizeof(shinf), SHGFI_DISPLAYNAME)) return -1; - if (!Bstrcmp(shinf.szDisplayName, fn)) + len = Bstrlen(shinf.szDisplayName); + + if (!Bstrncmp(shinf.szDisplayName, fn, len)) return 0; { char *tfn = Bstrtolower(Bstrdup(fn)); - if (!Bstrcmp(shinf.szDisplayName, tfn)) + if (!Bstrncmp(shinf.szDisplayName, tfn, len)) { Bfree(tfn); return 0; @@ -700,7 +703,7 @@ static int32_t check_filename_mismatch(const char *filename, int32_t ofs) Bstrupr(tfn); - if (!Bstrcmp(shinf.szDisplayName, tfn)) + if (!Bstrncmp(shinf.szDisplayName, tfn, len)) { Bfree(tfn); return 0;