From 7c38d9e2a5c994b4aad909ca05de7c422d7788a4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 Jul 2014 13:10:58 +0000 Subject: slightly more correct version git-svn-id: http://svn.miranda-ng.org/main/trunk@9886 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/database/database.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 0b1b8f8b06..e9f56bac81 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -247,16 +247,22 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n if (hFind != INVALID_HANDLE_VALUE) { do { // make sure the first hit is actually a *.dat file - if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T(".."))) { - TCHAR newProfile[MAX_PATH]; - mir_sntprintf(newProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName); - if (_taccess(newProfile, 0) != 0) - continue; + if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !_tcscmp(ffd.cFileName, _T(".")) || !_tcscmp(ffd.cFileName, _T(".."))) + continue; + TCHAR newProfile[MAX_PATH]; + mir_sntprintf(newProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName); + if (_taccess(newProfile, 0) != 0) + continue; + + switch (touchDatabase(newProfile, NULL)) { + case 0: + if (++found == 1 && nodprof) + _tcsncpy_s(szProfile, cch, newProfile, _TRUNCATE); + + case EGROKPRF_OBSOLETE: allfound++; - if (touchDatabase(newProfile, NULL) == 0) - if (++found == 1 && nodprof) - _tcsncpy_s(szProfile, cch, newProfile, _TRUNCATE); + break; } } while (FindNextFile(hFind, &ffd)); -- cgit v1.2.3