示例#1
0
bool Handshake::doSanityCheck( const char* RFACTOR_PATH, const char* PLUGIN_PATH, char* fileBuffer )
{
    logg( "Doing a sanity check..." );
    
    bool warningsDetected = false;
    
    if ( checkDirectoryExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\log", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: log directory not found. Using rFactor root folder." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( checkDirectoryExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD", fileBuffer ), false ) == 0 )
    {
        logg( "    ERROR: rfDynHud directory not found in the rFactor Plugins folder. The plugin won't work." );
        return ( false );
    }
    
    if ( checkFileExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\rfdynhud.jar", fileBuffer ), false ) == 0 )
    {
        logg( "    ERROR: rfdynhud.jar not found in the rFactor Plugins\\rfDynHUD folder. The plugin won't work." );
        return ( false );
    }
    
    //readIniString( ini_filename, "GENERAL", "numArchivedLogFiles", "5", buffer, 16 );
    if ( checkDirectoryExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\config", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: config directory not found in the rFactor Plugins\\rfDynHUD folder. Fallback config will be used.\r\nUse the editor to create a valid config and store it as overlay.ini in the config folder. Please see the readme.txt in the config folder for more info." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( checkFileExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\config\\overlay.ini", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: overlay.ini configuration file not found in the rFactor Plugins\\rfDynHUD\\config folder. If no mod specific configurations are stored (which is not checked here), fallback config will be used.\r\nUse the editor to create a valid config and store it as overlay.ini in the config folder. Please see the readme.txt in the config folder for more info." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( checkFileExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\config\\three_letter_codes.ini", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: three_letter_codes.ini file not found in the rFactor Plugins\\rfDynHUD\\config folder. Driver names will be displayed in full length regardless of the configuration.\r\nPlease see the readme.txt in the config folder for more info." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( warningsDetected )
        logg( "Sanity check passed, but warnings detected. The plugin may not work as expected." );
    else
        logg( "Sanity check passed." );
    
    return ( true );
}
示例#2
0
char* guessJavaHome()
{
    char* buffer = (char*)malloc( MAX_PATH );
    char* buffer7 = (char*)malloc( MAX_PATH );
    
    DWORD len = GetEnvironmentVariable( "ProgramFiles", buffer, MAX_PATH );
    DWORD len7 = GetEnvironmentVariable( "ProgramFiles", buffer, MAX_PATH );
    
    char* buff = buffer + len;
    memcpy( buff, "\\Java\\jre6", 11 );
    len += 11;
    
    char* result = (char*)malloc( len );
    memcpy( result, buffer, len );
    free( buffer );

	char* buff7 = buffer7 + len7;
    memcpy( buff7, "\\Java\\jre7", 11 );
    len7 += 11;
    
    char* result7 = (char*)malloc( len7 );
    memcpy( result7, buffer7, len7 );
    free( buffer7 );
    
	if ( checkDirectoryExists( result, false ) != 1 && checkDirectoryExists( result7, false ) != 1)
    {
        free( result );
        free( result7 );
        
        logg( "WARNING: Couldn't find 32 bit Java 6 or Java 7 Runtime Environment in the default folder." );
        
        return ( NULL );
    }
    if ( checkDirectoryExists( result7, false ) != 1)
	{
		JAVA_VERSION = 7;
		return ( result7 );
	}
	JAVA_VERSION = 6;
	return ( result );
}
示例#3
0
bool createDirectoryWithParents( const char* dirname )
{
    if ( checkDirectoryExists( dirname, false ) == 1 )
        return ( true );

    int slashPos = lastIndexOf( dirname, '\\' );
    if ( slashPos == -1 )
        return ( false );

    char* parent = (char*)malloc( slashPos + 1 );
    memcpy( parent, dirname, slashPos );
    parent[slashPos] = '\0';

    if ( !createDirectoryWithParents( parent ) )
    {
        free( parent );
        return ( false );
    }

    free( parent );

    return ( CreateDirectory( dirname, NULL ) == TRUE );
}