示例#1
0
intptr_t WINAPI GetContentDataW(struct GetContentDataInfo *Info)
{
	if (!Info)
		return FALSE;
	LPCWSTR FilePath = Info->FilePath;
	wchar_t** CustomData = NULL;

	for (size_t i = 0; i < Info->Count; i++)
	{
		if (!fsf.LStricmp(Info->Names[i], L"diz")
			|| !fsf.LStricmp(Info->Names[i], L"C0"))
		{
			CustomData = (wchar_t**)(Info->Values + i);
		}
	}

	if (!FilePath || !CustomData)
		return FALSE;
	
	const wchar_t* pszSlash = wcsrchr(FilePath, L'\\');
	if (!pszSlash || pszSlash <= FilePath) return FALSE;
	if (pszSlash[1] == 0) return FALSE; // Если хотят диз именно для папки - то нужно без слеша
	string  strPath(FilePath, pszSlash-FilePath);
	
	// оптимизацией чтения диз-файла занимается сам diz
	if (diz.Read(strPath) == 0)
	{
		// Если диз пустой - сразу выходим
		return FALSE;
	}

	
	const wchar_t* pszDiz = diz.GetDizTextAddr(pszSlash+1, L"", 0/*???*/);
	//if (!pszDiz || pszDiz[0] == 0) -- ConvertNameToShort занимает очень много времени
	//{
	//	string strShort;
	//	ConvertNameToShort(FilePath, strShort);
	//	pszDiz = diz.GetDizTextAddr(pszSlash+1, strShort, 0/*???*/);
	//}
	if (!pszDiz || pszDiz[0] == 0)
	{
		return FALSE;
	}
	
	size_t nLen = wcslen(pszDiz)+1;
	*CustomData = (wchar_t*)malloc(nLen*2);
	wcscpy(*CustomData, pszDiz);
	// Заменить некоторые символы
	wchar_t* pszTab = wcspbrk(*CustomData, L"\t");
	while (pszTab)
	{
		*pszTab = L' ';
		pszTab = wcspbrk(pszTab+1, L"\t");
	}

	return TRUE;
}
示例#2
0
intptr_t WINAPI GetContentFieldsW(const struct GetContentFieldsInfo *Info)
{
	for (size_t i = 0; i < Info->Count; i++)
	{
		if (!fsf.LStricmp(Info->Names[i], L"diz")
			|| !fsf.LStricmp(Info->Names[i], L"C0"))
			return 1;
	}
	return 0;
}
示例#3
0
void WINAPI FreeContentDataW(const struct GetContentDataInfo *Info)
{
	for (size_t i = 0; i < Info->Count; i++)
	{
		if (!fsf.LStricmp(Info->Names[i], L"diz")
			|| !fsf.LStricmp(Info->Names[i], L"C0"))
		{
			if (Info->Values[i])
			{
				wchar_t* ptr = (wchar_t*)Info->Values[i];
				if (ptr) free(ptr);
			}
		}
	}
}