/** add a path to the search paths */
void File_AddPath( char* directory ) {
	Bool found;
	Index dir_i;

	/* Check if it is a valid path */
	if( !directory ) {
		return;
	}

	/* Check if dictionary already exists */
	if( _stgFilePaths == NULL ) {
		_stgFilePaths = Stg_ObjectList_New();
	}
	
	/* Add path to global list */
	found = False;
	for( dir_i =  0; dir_i < _stgFilePaths->count; dir_i++ ){
		if( strcmp( directory, (char*)Stg_ObjectList_ObjectAt( _stgFilePaths, dir_i ) ) == 0 ) {
			found = True;
		}
	}
	
	if( !found ) {
		Stg_ObjectList_PointerAppend( _stgFilePaths, StG_Strdup( directory ), directory, deleteInputPathItem, 0, 0 ); 
	}
}
Beispiel #2
0
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	Stream* stream;

	Stg_ObjectList* directories;
	PluginLoader* plugin;

	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );

	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );
	BaseAutomation_Init( &argc, &argv );
	BaseExtensibility_Init( &argc, &argv );

	/* creating a stream */
	stream =  Journal_Register( Info_Type, __FILE__ );

	directories = Stg_ObjectList_New();
	Stg_ObjectList_PointerAppend( directories, StG_Strdup(LIB_DIR), "default dir", 0, 0, 0 );
	
	plugin = PluginLoader_NewLocal( "LocalPlugin", directories );

	Journal_Firewall( plugin != NULL, stream, "Failed!\n" );

	Journal_Printf( stream, "PluginLoader_GetName(): %s\n", PluginLoader_GetName( plugin ) );
	Print( plugin, stream );

	Stg_Class_Delete( plugin );
	Stg_Class_Delete( directories );
	
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
                                                                                                                                    

	return 0;
}