Beispiel #1
0
int MaPlugin::QueryArchives(const unsigned char* pBuffer, DWORD dwBufferSize, const TCHAR* lpFileName, Array<ArchiveQueryResult*>& result)
{
	MaArchive* pResult = NULL;

	OEM_NAME_CREATE_CONST(lpFileName);

	if ( m_pfnIsArchive(lpFileNameA, pBuffer, dwBufferSize) )
	{
		//попробуем сделать страшное...
		int nArcType = -1;

		if ( m_pfnOpenArchive(lpFileNameA, &nArcType) )
		{
			if ( (nArcType >= 0) && (nArcType < m_pFormatInfo.count()) )
			{
				ArchiveQueryResult* pResult = new ArchiveQueryResult;

				pResult->uidPlugin = m_uid;
				pResult->uidFormat = m_pFormatInfo[nArcType].uid;

				result.add(pResult);
			}

			struct ArcInfo MaArcInfo;

			if ( m_pfnCloseArchive )
				m_pfnCloseArchive (&MaArcInfo);
		}
	}

	OEM_NAME_DELETE_CONST(lpFileName);

	return NULL;
}
Beispiel #2
0
bool MaPlugin::OpenArchive(const TCHAR* lpFileName)
{
	OEM_NAME_CREATE_CONST(lpFileName);

	int nType = 0;

	bool bResult = m_pfnOpenArchive(lpFileNameA, &nType);

	OEM_NAME_DELETE_CONST(lpFileName);
	
	return bResult;
}
Beispiel #3
0
bool LoadLanguageFile (
		const TCHAR* lpFileName,
		const TCHAR* lpLanguage,
		TCHAR**& pStrings,
		int& nStringsCount
		)
{
	bool bResult = false;

	HANDLE hFile = CreateFile (
			lpFileName,
			GENERIC_READ,
			FILE_SHARE_READ,
			NULL,
			OPEN_EXISTING,
			FILE_FLAG_SEQUENTIAL_SCAN,
			NULL
			);

	if ( hFile != INVALID_HANDLE_VALUE )
	{
		DWORD dwFileSize = GetFileSize (hFile, NULL);
		DWORD dwRead = 0;

		char* lpBuffer = new char[dwFileSize];
		memset(lpBuffer, 0, dwFileSize);

		char* lpEndOfBuffer;

		ReadFile (hFile, lpBuffer, dwFileSize, &dwRead, NULL);

		lpEndOfBuffer = (char*)((DWORD_PTR)lpBuffer+dwRead-1);

		OEM_NAME_CREATE_CONST(lpLanguage);			

		if ( ScanMsgsBuf (
				lpBuffer,
				lpEndOfBuffer,
				lpLanguageA,
				NULL, //
				&nStringsCount
				) ) // correct language found!
		{
			pStrings = new TCHAR*[nStringsCount];
			memset (pStrings, 0, nStringsCount*sizeof(TCHAR*));

			ScanMsgsBuf (
					lpBuffer,
					lpEndOfBuffer,
					NULL,  // we already know, this file has a correct language
					pStrings,
					NULL
					);

			bResult = true;
		}

		OEM_NAME_DELETE_CONST(lpLanguage);

		delete [] lpBuffer;

		CloseHandle (hFile);
	}

	return bResult;
}