How do I get the path to the game directory?

Discussion in 'Game Modifications' started by Phloxicon, Aug 9, 2009.

  1. Phloxicon Newbie

    Member Since:
    Mar 26, 2009
    Message Count:
    17
    Trophy Points:
    0
    I just want to be able to do something along the lines of:
    openFile( PATH_TO_FILE, "/test/test.file" );

    It's figuring out how to get PATH_TO_FILE that's stopping me. What's the call for this?

    Thanks :)
  2. Phloxicon Newbie

    Member Since:
    Mar 26, 2009
    Message Count:
    17
    Trophy Points:
    0
    Found it here:
    http://fr.pastebin.ca/raw/971440

    Code:
    bool RunLuaFile( const char* scriptname )
    {
    	char char_filename[ _MAX_PATH ];
    	char char_output_full_filename[ _MAX_PATH ];
    
    	strcpy( char_filename, scriptname );
    	filesystem->RelativePathToFullPath( char_filename, "MOD", char_output_full_filename, sizeof( char_output_full_filename ));
    
    	const char *constcharpointer = reinterpret_cast<const char *>( char_output_full_filename );
    	Msg( "constcharpointer = %s\n", constcharpointer );
    	if ( !filesystem->FileExists( constcharpointer ))
    	{
    		//cvar->ConsoleColorPrintf( LUA_ERROR_PRINT_COLOUR, "[Lua] IFileSystem Cannot find the file: %s\n", constcharpointer );
    		Warning( "\nFile doesn't exist\n" );
    		return false;
    	}
    
    	return true;
    }