From 5524ec8d8ee9ca4f05e968516f2223e24bd65d82 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 26 Mar 2008 05:04:35 +0000 Subject: [PATCH] Fixed amb1534 - VDF files with a ".vdf" that wasn't at the very end of the filename were being opened by MM:S. This was due to the use of strstr. --HG-- branch : sourcemm-1.4.4 extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.4%40686 --- sourcemm/sourcemm.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sourcemm/sourcemm.cpp b/sourcemm/sourcemm.cpp index 0e3abb4..6daed69 100644 --- a/sourcemm/sourcemm.cpp +++ b/sourcemm/sourcemm.cpp @@ -704,6 +704,7 @@ void LookForVDFs(const char *dir) HANDLE hFind; WIN32_FIND_DATA fd; char error[255]; + int extidx; g_SmmAPI.PathFormat(path, sizeof(path), "%s\\*.*", dir); if ((hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE) @@ -727,7 +728,8 @@ void LookForVDFs(const char *dir) { continue; } - if (strstr(fd.cFileName, ".vdf") == NULL) + extidx = strlen(fd.cFileName) - 4; + if (extidx < 0 || stricmp(&fd.cFileName[extidx], ".vdf")) { continue; } @@ -753,7 +755,8 @@ void LookForVDFs(const char *dir) { continue; } - if (strstr(pEnt->d_name, ".vdf") == NULL) + extidx = strlen(fd.cFileName) - 4; + if (extidx < 0 || stricmp(&fd.cFileName[extidx], ".vdf")) { continue; }