Exemplo n.º 1
0
bool CPlugins::CopyPlugins(const stdstr & DstDir) const
{
    //Copy GFX Plugin
    CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
    CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
    dstGfxPlugin.SetName(stdstr_f("%s-copy", dstGfxPlugin.GetName().c_str()).c_str());

    if (!dstGfxPlugin.DirectoryExists())
    {
        dstGfxPlugin.DirectoryCreate();
    }
    if (!srcGfxPlugin.CopyTo(dstGfxPlugin))
    {
        WriteTrace(TracePlugins, TraceError, "failed to copy %s to %s", (const char *)srcGfxPlugin, (const char *)dstGfxPlugin);
        return false;
    }

    //Copy m_Audio Plugin
    CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
    CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
    dstAudioPlugin.SetName(stdstr_f("%s-copy", dstAudioPlugin.GetName().c_str()).c_str());
    if (!dstAudioPlugin.DirectoryExists())
    {
        dstAudioPlugin.DirectoryCreate();
    }
    if (!srcAudioPlugin.CopyTo(dstAudioPlugin))
    {
        return false;
    }
    //Copy RSP Plugin
    CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
    CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
    dstRSPPlugin.SetName(stdstr_f("%s-copy", dstRSPPlugin.GetName().c_str()).c_str());
    if (!dstRSPPlugin.DirectoryExists())
    {
        dstRSPPlugin.DirectoryCreate();
    }
    if (!srcRSPPlugin.CopyTo(dstRSPPlugin))
    {
        return false;
    }

    //Copy Controller Plugin
    CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
    CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
    dstContPlugin.SetName(stdstr_f("%s-copy", dstContPlugin.GetName().c_str()).c_str());
    if (!dstContPlugin.DirectoryExists())
    {
        dstContPlugin.DirectoryCreate();
    }
    if (!srcContPlugin.CopyTo(dstContPlugin))
    {
        return false;
    }
    return true;
}
Exemplo n.º 2
0
const char * TraceModule(uint32_t module)
{
    ModuleNameMap::const_iterator itr = g_ModuleNames.find(module);
    if (itr != g_ModuleNames.end())
    {
        return itr->second.c_str();
    }
    static stdstr Unknown;
    Unknown.Format("Unknown (%d)", module);
    return Unknown.c_str();
}
Exemplo n.º 3
0
bool CPlugins::CopyPlugins (  const stdstr & DstDir ) const 
{	
	//Copy GFX Plugin
	CPath srcGfxPlugin(m_PluginDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
	CPath dstGfxPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
	
	if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0) 
	{
		if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.DirectoryCreate(); }
		if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false)) 
		{
			return false;
		}
	}

	//Copy m_Audio Plugin
	CPath srcAudioPlugin(m_PluginDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
	CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
	if (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) {
		if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.DirectoryCreate(); }
		if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false))
		{
			return false;
		}
	}

	//Copy RSP Plugin
	CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
	CPath dstRSPPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
	if (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) {
		if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.DirectoryCreate(); }
		if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false))
		{
			return false;
		}
	}

	//Copy Controller Plugin
	CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
	CPath dstContPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
	if (!srcContPlugin.CopyTo(dstContPlugin))
	{
		if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.DirectoryCreate(); }
		if (!CopyFile(srcContPlugin,dstContPlugin,false))
		{
			DWORD dwError = GetLastError();
			dwError = dwError;
			return false;
		}
	}
	return true;
}
Exemplo n.º 4
0
bool CPlugins::CopyPlugins(const stdstr & DstDir) const
{
    //Copy GFX Plugin
    CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
    CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());

    if (!dstGfxPlugin.DirectoryExists())
    {
        dstGfxPlugin.DirectoryCreate();
    }
    if (!srcGfxPlugin.CopyTo(dstGfxPlugin))
    {
        return false;
    }

    //Copy m_Audio Plugin
    CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
    CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
    if (!dstAudioPlugin.DirectoryExists())
    {
        dstAudioPlugin.DirectoryCreate();
    }
    if (!srcAudioPlugin.CopyTo(dstAudioPlugin))
    {
        return false;
    }

    //Copy RSP Plugin
    CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
    CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
    if (!dstRSPPlugin.DirectoryExists())
    {
        dstRSPPlugin.DirectoryCreate();
    }
    if (!srcRSPPlugin.CopyTo(dstRSPPlugin))
    {
        return false;
    }

    //Copy Controller Plugin
    CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
    CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
    if (!dstContPlugin.DirectoryExists())
    {
        dstContPlugin.DirectoryCreate();
    }
    if (!srcContPlugin.CopyTo(dstContPlugin))
    {
        return false;
    }
    return true;
}
Exemplo n.º 5
0
const char * TraceSeverity(uint8_t severity)
{
    switch (severity)
    {
    case TraceError: return "Error";
    case TraceWarning: return "Warning";
    case TraceNotice: return "Notice";
    case TraceInfo: return "Info";
    case TraceDebug: return "Debug";
    case TraceVerbose: return "Verbose";
    }

    static stdstr Unknown;
    Unknown.Format("Unknown (%d)", (int32_t)severity);
    return Unknown.c_str();
}
Exemplo n.º 6
0
static void LoadPlugin (SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type) 
{ 
	if (plugin != NULL)
	{
		return;
	}
	FileName = g_Settings->LoadStringVal(PluginSettingID);
	CPath PluginFileName(PluginDir,FileName.c_str());
	plugin = new plugin_type();
	if (plugin)
	{
		WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading (%s): Starting",type,(LPCTSTR)PluginFileName);
		if (plugin->Load(PluginFileName))
		{
			WriteTraceF(TraceLevel,__FUNCTION__ ": %s Current Ver: %s",type,plugin->PluginName());
			g_Settings->SaveString(PluginVerSettingID,plugin->PluginName());
		}
		else
		{
			WriteTraceF(TraceError,__FUNCTION__ ": Failed to load %s",(LPCTSTR)PluginFileName);
			delete plugin;
			plugin = NULL;
		}
		WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading Done",type);
	} 
	else
	{
		WriteTraceF(TraceError,__FUNCTION__ ": Failed to allocate %s plugin",type);
	}
}
Exemplo n.º 7
0
stdstr CMainMenu::GetFileLastMod (stdstr FileName)
{
	HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, FILE_SHARE_READ,NULL,
		OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
	if (hFile == INVALID_HANDLE_VALUE) 
	{
		return "";
	}
	FILETIME CreationTime, LastAccessTime, LastWriteTime;
	stdstr LastMod;
	if (GetFileTime(hFile,&CreationTime,&LastAccessTime,&LastWriteTime))
	{
		SYSTEMTIME stUTC, stLocal;

		 // Convert the last-write time to local time.
		FileTimeToSystemTime(&LastWriteTime, &stUTC);
		SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
		
		LastMod.Format(" [%d/%02d/%02d %02d:%02d]",
			stLocal.wYear, stLocal.wMonth, stLocal.wDay,stLocal.wHour, stLocal.wMinute);
	}
	CloseHandle(hFile);

	return LastMod;
}
Exemplo n.º 8
0
static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy)
{
    if (plugin != NULL)
    {
        return;
    }
    FileName = g_Settings->LoadStringVal(PluginSettingID);
    CPath PluginFileName(PluginDir, FileName.c_str());
    if (IsCopy)
    {
        PluginFileName.SetName(stdstr_f("%s-copy", PluginFileName.GetName().c_str()).c_str());
    }
    plugin = new plugin_type();
    if (plugin)
    {
        WriteTrace(TraceLevel, TraceDebug, "%s Loading (%s): Starting", type, (const char *)PluginFileName);
        if (plugin->Load(PluginFileName))
        {
            WriteTrace(TraceLevel, TraceDebug, "%s Current Ver: %s", type, plugin->PluginName());
            g_Settings->SaveString(PluginVerSettingID, plugin->PluginName());
        }
        else
        {
            WriteTrace(TraceLevel, TraceError, "Failed to load %s", (const char *)PluginFileName);
            delete plugin;
            plugin = NULL;
        }
        WriteTrace(TraceLevel, TraceDebug, "%s Loading Done", type);
    }
    else
    {
        WriteTrace(TraceLevel, TraceError, "Failed to allocate %s plugin", type);
    }
}
bool CSettingTypeApplicationPath::Load(int Index, stdstr & Value) const
{
    bool bRes = CSettingTypeApplication::Load(Index, Value);
    if (bRes)
    {
        if (Value.substr(0, 2) == ".\\" || Value.substr(0, 2) == "./" ||
            Value.substr(0, 3) == "..\\" || Value.substr(0, 3) == "../")
        {
            CPath FullFilePath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), ""), RelativePath(Value);
            FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
            FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());

            Value = (const std::string &)FullFilePath;
        }
    }
    return bRes;
}
Exemplo n.º 10
0
void CSettingTypeApplication::Save ( int /*Index*/, const stdstr & Value )
{
    if (!m_UseRegistry)
    {
        m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),Value.c_str());
    } else {
        g_Notify->BreakPoint(__FILEW__,__LINE__);
    }
}
bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
{
	bool bRes = CSettingTypeApplication::Load(Index,Value);
#ifdef WIN32
	if (bRes)
	{
		if (Value.substr(0,2) == ".\\" || Value.substr(0,2) == "./" ||
			Value.substr(0,3) == "..\\" || Value.substr(0,3) == "../")
		{
			CPath FullFilePath(CPath::MODULE_DIRECTORY), RelativePath(Value);
			FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
			FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());

            Value = (const std::string &)FullFilePath;
		}
	}
#endif
	return bRes;
}
Exemplo n.º 12
0
void CPlugins::CreatePluginDir ( const stdstr & DstDir ) const {
   char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], 
	   fname[_MAX_FNAME], ext[_MAX_EXT];
	_splitpath(DstDir.c_str(), drive, dir, fname, ext );			
	_makepath(path_buffer, drive, dir, "", "" );
	if (CreateDirectory(path_buffer,NULL) == 0 && GetLastError() == ERROR_PATH_NOT_FOUND) 
	{
		path_buffer[strlen(path_buffer) - 1] = 0;
		CreatePluginDir(stdstr(path_buffer));
		CreateDirectory(path_buffer,NULL);
	}
}
void CSettingTypeGame::Save ( int Index, const stdstr & Value )
{
	Save(Index,Value.c_str()); 
}
Exemplo n.º 14
0
void CSettings::SaveStringIndex( SettingID Type, int index, const stdstr & Value )
{
	SaveStringIndex(Type,index,Value.c_str());
}
void CSettingTypeApplication::Save(int /*Index*/, const stdstr & Value)
{
    m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), Value.c_str());
}