示例#1
0
SString SharedUtil::GetMTADataPath ( void )
{
    return PathJoin ( GetSystemCommonAppDataPath(), "MTA San Andreas All", GetMajorVersionString () );
}
示例#2
0
SString SharedUtil::GetMTATempPath ( void )
{
    return PathJoin ( GetSystemTempPath(), "MTA" + GetMajorVersionString () );
}
示例#3
0
SString SharedUtil::GetMTADataPath(void)
{
    return PathJoin(GetSystemCommonAppDataPath(), GetProductCommonDataDir(), GetMajorVersionString());
}
示例#4
0
//////////////////////////////////////////////////////////
//
// CInstallManager::_ProcessLayoutChecks
//
// Make sure new reg/dir structure is ok
//
//////////////////////////////////////////////////////////
SString CInstallManager::_ProcessLayoutChecks ( void )
{
    //
    // Validation
    //

    // Check data dir exists
    {
        if ( !DirectoryExists ( GetMTADataPath () ) )
            ShowLayoutError ( "[Data directory not present]" );   // Can't find directory
    }

    // Check reg key exists
    //{
    //    if ( GetRegistryValue ( "", "Last Install Location" ).empty () )
    //        ShowLayoutError ( "[Registry key not present]" );   // Can't find reg key
    //}

    // Check data dir writable
    {
        SString strTestFilePath = PathJoin ( GetMTADataPath (), "testdir", "testfile.txt" );

        FileDelete ( strTestFilePath );
        RemoveDirectory ( ExtractPath ( strTestFilePath ) );

        SString strContent = "test";
        if ( !FileSave ( strTestFilePath, strContent ) )
            ShowLayoutError ( "[Data directory not writable]" );   // Can't save file

        FileDelete ( strTestFilePath );
        RemoveDirectory ( ExtractPath ( strTestFilePath ) );
    }

    // Check reg key writable
    {
        RemoveRegistryKey ( "testkeypath" );

        SString strValue = GetTimeString( true, true );
        SetRegistryValue ( "testkeypath", "testname", strValue );
        SString strValueCheck = GetRegistryValue ( "testkeypath", "testname" );
        if ( strValueCheck != strValue )
            ShowLayoutError ( "[Registry key not writable]" );   // Can't write reg key

        RemoveRegistryKey ( "testkeypath" );
    }

    // Check install dir writable
    {
        SString strTestFilePath = CalcMTASAPath ( PathJoin ( "mta", "writetest.txt" ) );

        FileDelete ( strTestFilePath );

        SString strContent = "test";
        if ( !FileSave ( strTestFilePath, strContent ) )
            ShowLayoutError ( "[Install directory not writable]" );   // Can't save file

        FileDelete ( strTestFilePath );
    }

    //
    // Migration
    //

    // If news/temp/upcache folder doesn't exist in new, but does in old place, move it
    {
        const char* folders[] = { "news", "temp", "upcache" };
        for ( uint i = 0 ; i < NUMELMS( folders ) ; i++ )
        {
            SString strSrc = PathJoin ( GetSystemLocalAppDataPath (), "MTA San Andreas " + GetMajorVersionString (), folders[i] );
            SString strDest = PathJoin ( GetMTADataPath (), folders[i] );
            if ( !DirectoryExists ( strDest ) && DirectoryExists ( strSrc ) )
                MoveFile ( strSrc, strDest );
        }
    }

    // If aero option reg entry doesn't exist in new, but does in old place, move it
    {
        if ( GetApplicationSetting ( "aero-enabled" ).empty () )
        {
            SString strLegacyValue = GetVersionRegistryValueLegacy ( GetMajorVersionString (), PathJoin ( "Settings", "general" ), "aero-enabled" );
            if ( !strLegacyValue.empty () )
                SetApplicationSettingInt ( "aero-enabled", atoi ( strLegacyValue ) );
            else
                SetApplicationSettingInt ( "aero-enabled", 1 );
        }
    }

    return "ok";
}
示例#5
0
bool SharedUtil::RemoveRegistryKey ( const SString& strPath )
{
    return DeleteRegistryKey ( HKEY_LOCAL_MACHINE, MakeVersionRegistryPath ( GetMajorVersionString (), strPath ) );
}
示例#6
0
SString SharedUtil::GetRegistryValue ( const SString& strPath, const SString& strName )
{
    return ReadRegistryStringValue ( HKEY_LOCAL_MACHINE, MakeVersionRegistryPath ( GetMajorVersionString (), strPath ), strName, NULL );
}
示例#7
0
//
// Registry values
// 
// Get/set registry values for the current version
void SharedUtil::SetRegistryValue ( const SString& strPath, const SString& strName, const SString& strValue )
{
    WriteRegistryStringValue ( HKEY_LOCAL_MACHINE, MakeVersionRegistryPath ( GetMajorVersionString (), strPath ), strName, strValue );
}