From 2d3b85b61fbd644508fac957e194a1618830191b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 Jul 2014 13:32:19 +0000 Subject: default profile verification git-svn-id: http://svn.miranda-ng.org/main/trunk@9887 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/database/database.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index e9f56bac81..4b496dca48 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -231,7 +231,7 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n moveProfileDirProfiles(profiledir); moveProfileDirProfiles(profiledir, FALSE); - bool nodprof = szProfile[0] == 0; + bool nodprof = (*szProfile == 0); bool reqfd = !nodprof && (_taccess(szProfile, 0) == 0 || shouldAutoCreate(szProfile)); bool shpm = showProfileManager(); @@ -269,11 +269,11 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n FindClose(hFind); } - reqfd = !shpm && found == 1 && nodprof; + reqfd = (!shpm && found == 1 && nodprof); } if (noProfiles) - *noProfiles = allfound == 0; + *noProfiles = (allfound == 0); if (nodprof && !reqfd) szProfile[0] = 0; @@ -284,6 +284,9 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n // returns 1 if a default profile should be selected instead of showing the manager. static int getProfileAutoRun(TCHAR *szProfile) { + if (*szProfile == 0) + return false; + TCHAR Mgr[32]; GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T(""), Mgr, SIZEOF(Mgr), mirandabootini); if (_tcsicmp(Mgr, _T("never"))) @@ -303,6 +306,12 @@ static int getProfile(TCHAR *szProfile, size_t cch) getDefaultProfile(szProfile, cch, g_profileDir); getProfileCmdLine(szProfile, cch, g_profileDir); getProfileDefault(szProfile, cch, g_profileDir); + + // if default profile was found, verify it + if (*szProfile) + if (touchDatabase(szProfile, 0) != 0) + *szProfile = 0; + if (IsInsideRootDir(g_profileDir, true)) { MessageBox(NULL, TranslateT("Profile cannot be placed into Miranda root folder.\nPlease move Miranda profile to some other location."), -- cgit v1.2.3