コード例 #1
0
void CApplicationImpl::OpenDataFile(const CString& csFileName)
{ 
	if (!IsDataFileOpened(csFileName))
	{
		Database::IDataFile* pTempDataFile = GetDatabase()->OpenDataFile(csFileName);
		try
		{
			if (pTempDataFile->IsEmpty())
			{
				CreateDefaultContent(pTempDataFile);
			}
			else
			{
				CheckContent(pTempDataFile);
			}

			CheckModules(pTempDataFile);

			if (!m_spDataFile.is_null())
			{
				GetDatabase()->CloseDataFile(m_spDataFile.get());
			}
			m_spDataFile = pTempDataFile;

			m_mru.AddToList(m_spDataFile->GetFileName());
			m_mru.WriteToRegistry(GetOptionsPath(_T("Application")));

			UpdateViews(UNM_FILE_OPENED, (WPARAM)m_spDataFile->GetFileName());
		}
		catch(...)
		{
			// close new opened temp data file and throw exception up
			GetDatabase()->CloseDataFile(pTempDataFile);
			throw;
		}
	}
}
コード例 #2
0
ファイル: CPlugin.cpp プロジェクト: Arkshine/amxmodx
void CPluginMngr::CPlugin::Finalize()
{
	char buffer[128];
	int old_status = status;

	if (CheckModules(&amx, buffer))
	{
		if (amx_Register(&amx, core_Natives, -1) != AMX_ERR_NONE)
		{
			Handler *pHandler = (Handler *)amx.userdata[UD_HANDLER];
			int res = 0;

			if (pHandler->IsNativeFiltering())
				res = amx_CheckNatives(&amx, native_handler);

			if (!res)
			{
				status = ps_bad_load;
				sprintf(buffer, "Plugin uses an unknown function (name \"%s\") - check your modules.ini.", no_function);
				errorMsg = buffer;
				amx.error = AMX_ERR_NOTFOUND;
			} else {
				amx_RegisterToAny(&amx, invalid_native);
			}
		}
	} else {
		status = ps_bad_load;
		errorMsg = buffer;
		amx.error = AMX_ERR_NOTFOUND;
	}

	if (old_status != status)
	{
		AMXXLOG_Log("[AMXX] Plugin \"%s\" failed to load: %s", name.chars(), errorMsg.chars());
	}
}