From d19cedd4ebe37cc15be9dbf6deec1d6c4eb26a72 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 19 Nov 2008 01:14:16 -0600 Subject: [PATCH] Changed FindFirstFile code in LookForVDFs to look for *.vdf instead of *.* --- core-legacy/sourcemm.cpp | 17 +++++------------ core/metamod.cpp | 17 +++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/core-legacy/sourcemm.cpp b/core-legacy/sourcemm.cpp index dea541e..8871936 100644 --- a/core-legacy/sourcemm.cpp +++ b/core-legacy/sourcemm.cpp @@ -704,17 +704,19 @@ void LoadFromVDF(const char *file) void LookForVDFs(const char *dir) { char path[MAX_PATH]; - int extidx; #if defined _MSC_VER HANDLE hFind; WIN32_FIND_DATA fd; char error[255]; - g_SmmAPI.PathFormat(path, sizeof(path), "%s\\*.*", dir); + g_SmmAPI.PathFormat(path, sizeof(path), "%s\\*.vdf", dir); if ((hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE) { DWORD dw = GetLastError(); + if (dw == ERROR_FILE_NOT_FOUND) + return; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, @@ -728,16 +730,6 @@ void LookForVDFs(const char *dir) do { - if (strcmp(fd.cFileName, ".") == 0 - || strcmp(fd.cFileName, "..") == 0) - { - continue; - } - extidx = strlen(fd.cFileName) - 4; - if (extidx < 0 || stricmp(&fd.cFileName[extidx], ".vdf")) - { - continue; - } g_SmmAPI.PathFormat(path, sizeof(path), "%s\\%s", dir, fd.cFileName); LoadFromVDF(path); } while (FindNextFile(hFind, &fd)); @@ -746,6 +738,7 @@ void LookForVDFs(const char *dir) #else DIR *pDir; struct dirent *pEnt; + int extidx; if ((pDir = opendir(dir)) == NULL) { diff --git a/core/metamod.cpp b/core/metamod.cpp index e8290af..c52a639 100644 --- a/core/metamod.cpp +++ b/core/metamod.cpp @@ -1436,17 +1436,19 @@ static void LookForVDFs(const char *dir) { char path[MAX_PATH]; - int extidx; #if defined _MSC_VER HANDLE hFind; WIN32_FIND_DATA fd; char error[255]; - g_Metamod.PathFormat(path, sizeof(path), "%s\\*.*", dir); + g_Metamod.PathFormat(path, sizeof(path), "%s\\*.vdf", dir); if ((hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE) { DWORD dw = GetLastError(); + if (dw == ERROR_FILE_NOT_FOUND) + return; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, @@ -1460,16 +1462,6 @@ LookForVDFs(const char *dir) do { - if (strcmp(fd.cFileName, ".") == 0 - || strcmp(fd.cFileName, "..") == 0) - { - continue; - } - extidx = strlen(fd.cFileName) - 4; - if (extidx < 0 || stricmp(&fd.cFileName[extidx], ".vdf")) - { - continue; - } g_Metamod.PathFormat(path, sizeof(path), "%s\\%s", dir, fd.cFileName); ProcessVDF(path); } while (FindNextFile(hFind, &fd)); @@ -1478,6 +1470,7 @@ LookForVDFs(const char *dir) #else DIR *pDir; struct dirent *pEnt; + int extidx; if ((pDir = opendir(dir)) == NULL) {