示例#1
0
static void TVPWriteHWELogFile()
{
	TVPEnsureDataPathDirectory();
	TJS_nstrcpy(TVPHWExceptionLogFilename, TVPNativeDataPath.c_str());
	TJS_nstrcat(TVPHWExceptionLogFilename, "hwexcept.log");
	TVPHWExceptionLogHandle = CreateFile(TVPHWExceptionLogFilename, GENERIC_WRITE,
		FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

	if(TVPHWExceptionLogHandle == INVALID_HANDLE_VALUE) return;
	DWORD filesize;
	filesize = GetFileSize(TVPHWExceptionLogHandle, NULL);
	SetFilePointer(TVPHWExceptionLogHandle, filesize, NULL, FILE_BEGIN);

	// write header
	const char headercomment[] =
		"THIS IS A HARDWARE EXCEPTION LOG FILE OF KIRIKIRI. "
		"PLEASE SEND THIS FILE TO THE AUTHOR WITH *.console.log FILE. ";
	DWORD written = 0;
	for(int i = 0; i < 4; i++)
		WriteFile(TVPHWExceptionLogHandle, "----", 4, &written, NULL);
	WriteFile(TVPHWExceptionLogHandle, headercomment, sizeof(headercomment)-1,
		&written, NULL);
	for(int i = 0; i < 4; i++)
		WriteFile(TVPHWExceptionLogHandle, "----", 4, &written, NULL);
		

	// write version
	WriteFile(TVPHWExceptionLogHandle, &TVPVersionMajor,
		sizeof(TVPVersionMajor), &written, NULL);
	WriteFile(TVPHWExceptionLogHandle, &TVPVersionMinor,
		sizeof(TVPVersionMinor), &written, NULL);
	WriteFile(TVPHWExceptionLogHandle, &TVPVersionRelease,
		sizeof(TVPVersionRelease), &written, NULL);
	WriteFile(TVPHWExceptionLogHandle, &TVPVersionBuild,
		sizeof(TVPVersionBuild), &written, NULL);

	// write tTVPHWExceptionData
	WriteFile(TVPHWExceptionLogHandle, &TVPLastHWExceptionData,
		sizeof(TVPLastHWExceptionData), &written, NULL);


	// close the handle
	if(TVPHWExceptionLogHandle != INVALID_HANDLE_VALUE)
		CloseHandle(TVPHWExceptionLogHandle);

}
示例#2
0
//---------------------------------------------------------------------------
void tTVPSusieArchivePlugin::GetFileList(std::wstring localname,
	std::vector<tTVPSusieFileRecord> &dest)
{
	// retrieve file list
	TVPAddLog( TVPFormatMessage(TVPInfoListingFiles, ttstr(localname.c_str()) ) );

	HLOCAL infohandle = NULL;
	int errorcode = 0xff&GetArchiveInfo(const_cast<LPSTR>(ttstr(localname).AsNarrowStdString().c_str()), 0, 0x00, &infohandle);
	if(infohandle == NULL)
	{
		TVPThrowExceptionMessage(TVPSusiePluginError,
			ttstr(TJS_W("tTVPSusieArchivePlugin::GetArchiveInfo failed, errorcode = ")) +
			ttstr((tjs_int)errorcode));
	}
	else
	{
		if(errorcode != 0)
		{
			TVPAddLog(TJS_W("Warning : invalid errorcode ") + ttstr((tjs_int)errorcode) +
				TJS_W(" was returned from tTVPSusieArchivePlugin::GetArchiveInfo, ")
					TJS_W("continuing anyway."));
		}
	}


	const tTVPSusieFileInfo *info = (const tTVPSusieFileInfo*)LocalLock(infohandle);
	if(info == NULL)
	{
		TVPThrowExceptionMessage(TVPSusiePluginError,
			ttstr(TJS_W("tTVPSusieArchivePlugin::GetArchiveInfo failed : invalid memory block.")));
	}

	try
	{
		while(info->method[0])
		{
			if(info->filename[0])
			{
				char buf[401];
				TJS_nstrcpy(buf, info->path);
				TJS_nstrcat(buf, "/");
				TJS_nstrcat(buf, info->filename);

				tTVPSusieFileRecord record;
				record.Name = buf;
				tTVPArchive::NormalizeInArchiveStorageName(record.Name);
				record.Position = info->position;
				record.Size = info->filesize;

				dest.push_back(record);
			}

			info++;
		}

		// sort item vector by its name (required for tTVPArchive specification)
		std::stable_sort(dest.begin(), dest.end());
	}
	catch(...)
	{
		LocalUnlock(infohandle);
		LocalFree(infohandle);
		throw;
	}

	LocalUnlock(infohandle);
	LocalFree(infohandle);

	TVPAddLog(TJS_W("(info) ") + ttstr((tjs_int)dest.size()) + TJS_W(" files found."));
}