From d6331b6e7bbef9facc7e6c8bdc42ed4e7b58668d Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 1 Mar 2015 20:50:59 +0000 Subject: XFire: - Major cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@12294 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Xfire/src/searching4games.cpp | 47 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'protocols/Xfire/src/searching4games.cpp') diff --git a/protocols/Xfire/src/searching4games.cpp b/protocols/Xfire/src/searching4games.cpp index 93851ee494..2522a06f9b 100644 --- a/protocols/Xfire/src/searching4games.cpp +++ b/protocols/Xfire/src/searching4games.cpp @@ -46,10 +46,6 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) pos = strchr(ppath, '*'); if (pos) { - HANDLE fHandle; - WIN32_FIND_DATAA wfd; - BOOL weiter = TRUE; - if (pathwildcard) { strcpy_s(pathwildcard, XFIRE_MAX_STATIC_STRING_LEN, ppath); @@ -60,26 +56,29 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) pos++; //versuch die exe zu finden - fHandle = FindFirstFileA(ppath, &wfd); // . skippen - FindNextFileA(fHandle, &wfd); // .. auch skippen - - while ((FindNextFileA(fHandle, &wfd) && weiter == TRUE)) // erstes file - { - if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant + WIN32_FIND_DATAA wfd; + HANDLE fHandle = FindFirstFileA(ppath, &wfd); // . skippen + if (fHandle == INVALID_HANDLE_VALUE) + return FALSE; + if(FindNextFileA(fHandle, &wfd)) { // .. auch skippen + while (FindNextFileA(fHandle, &wfd)) // erstes file { - char temp[XFIRE_MAX_STATIC_STRING_LEN]; - - strcpy(temp, ppath); - *(temp + strlen(temp) - 1) = 0; - strcat(temp, wfd.cFileName); - strcat(temp, "\\"); - strcat(temp, pos); - - if (GetFileAttributesA(temp) != 0xFFFFFFFF) { //exe vorhanden???? unt hint? - //gefundenes in path kopieren - FindClose(fHandle); - strcpy(ppath, temp); - return TRUE; + if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant + { + char temp[XFIRE_MAX_STATIC_STRING_LEN]; + + strncpy(temp, ppath,XFIRE_MAX_STATIC_STRING_LEN-1); + *(temp + strlen(temp) - 1) = 0; + strncat(temp, wfd.cFileName,XFIRE_MAX_STATIC_STRING_LEN-1); + strncat(temp, "\\",XFIRE_MAX_STATIC_STRING_LEN-1); + strncat(temp, pos,XFIRE_MAX_STATIC_STRING_LEN-1); + + if (GetFileAttributesA(temp) != 0xFFFFFFFF) { //exe vorhanden???? unt hint? + //gefundenes in path kopieren + FindClose(fHandle); + strcpy(ppath, temp); + return TRUE; + } } } } @@ -291,7 +290,7 @@ void Scan4Games(LPVOID lparam) pos++; pos2 = strrchr(pos, '\\'); //key trennen - if (pos != 0) + if (pos2 != 0) { *pos2 = 0; pos2++; -- cgit v1.2.3