Пример #1
0
// returns 1 if something that looks like a profile is there
static void loadProfileByShortName(const TCHAR* src, TCHAR *szProfile, size_t cch, TCHAR *profiledir)
{
	TCHAR buf[MAX_PATH];
	_tcsncpy(buf, src, SIZEOF(buf));

	TCHAR *p = _tcsrchr(buf, '\\'); if (p) ++p; else p = buf;
	if (!isValidProfileName(buf) && *p)
		_tcscat(buf, _T(".dat"));

	TCHAR profileName[MAX_PATH], newProfileDir[MAX_PATH];
	_tcscpy(profileName, p);
	if (!isValidProfileName(profileName) && *p)
		_tcscat(profileName, _T(".dat"));

	_tcscpy(profileName, p);
	p = _tcsrchr(profileName, '.'); if (p) *p = 0;

	mir_sntprintf(newProfileDir, cch, _T("%s\\%s\\"), profiledir, profileName);
	PathToAbsoluteT(buf, szProfile, newProfileDir);

	if ( _tcschr(buf, '\\')) {
		_tcscpy(profiledir, szProfile);
		if (profileName[0]) {
			p = _tcsrchr(profiledir, '\\'); *p = 0;
			p = _tcsrchr(profiledir, '\\');
			if (p && _tcsicmp(p + 1, profileName) == 0)
				*p = 0;
		}
		else szProfile[0] = 0;
	}
}
Пример #2
0
void getProfileCmdLine(TCHAR * szProfile, size_t cch, TCHAR * profiledir)
{
	TCHAR buf[MAX_PATH];
	if (getProfileCmdLineArgs(buf, SIZEOF(buf))) 
	{
		TCHAR *p, profileName[MAX_PATH], newProfileDir[MAX_PATH];

		p = _tcsrchr(buf, '\\'); if (p) ++p; else p = buf; 

		if (!isValidProfileName(buf) && *p)
			_tcscat(buf, _T(".dat"));

		_tcscpy(profileName, p);
		p = _tcsrchr(profileName, '.'); if (p) *p = 0; 

		mir_sntprintf(newProfileDir, cch, _T("%s\\%s\\"), profiledir, profileName);
		pathToAbsoluteT(buf, szProfile, newProfileDir);

		if (_tcschr(buf, '\\')) 
		{
			_tcscpy(profiledir, szProfile);
			if (profileName[0])
			{
				p = _tcsrchr(profiledir, '\\'); *p = 0;
				p = _tcsrchr(profiledir, '\\');
				if (p && _tcsicmp(p + 1, profileName) == 0)
					*p = 0;
			}
			else
				szProfile[0] = 0;

		}
	}
}
Пример #3
0
static void getDefaultProfile(TCHAR * szProfile, size_t cch, TCHAR * profiledir)
{
	TCHAR defaultProfile[MAX_PATH];
	GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, SIZEOF(defaultProfile), mirandabootini);

	if (defaultProfile[0] == 0)
		return;

	TCHAR* res = Utils_ReplaceVarsT(defaultProfile);
	if (res) {
		mir_sntprintf(szProfile, cch, _T("%s\\%s\\%s%s"), profiledir, res, res, isValidProfileName(res) ? _T("") : _T(".dat"));
		mir_free(res);
	}
	else szProfile[0] = 0;
}
Пример #4
0
static void getDefaultProfile(TCHAR *szProfile, size_t cch, TCHAR *profiledir)
{
	TCHAR defaultProfile[MAX_PATH];
	GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, SIZEOF(defaultProfile), mirandabootini);

	if (defaultProfile[0] == 0)
		return;

	VARST res(defaultProfile);
	if (res)
		mir_sntprintf(szProfile, cch, _T("%s\\%s\\%s%s"), profiledir, (TCHAR*)res, (TCHAR*)res, isValidProfileName(res) ? _T("") : _T(".dat"));
	else
		szProfile[0] = 0;
}