Пример #1
0
//-------- Begin of function GameFileArray::load_all_game_header --------//
//
// Load all headers of all saved game files in current directory.
//
void GameFileArray::load_all_game_header(const char *path, const char *extStr)
{
	int       i;
	Directory gameDir;
	GameFile  gameFile;
	File      file;

	// ##### begin Gilbert 26/5 ######//
	String str;
	if( path && path[0] != '\0' )
	{
		str = path;
		str += "/";
		str += extStr;
	}
	else
	{
		str = extStr;
	}

	// gameDir.read( player_profile.save_game_path(extStr), 1 );  // 1-Sort file names
	gameDir.read( str, 1 );  // 1-Sort file names

	//-------- read in the headers of all game sets -------//

	zap();

	for( i=1 ; i<=gameDir.size() ; i++ )
	{
		// Directory store file name without path
		if( path && path[0] != '\0' )
		{
			str = path;
			str += "/";
			str += gameDir[i]->name;
		}
		else
		{
			str = gameDir[i]->name;
		}

		if( file.file_open( str, 1, 1 )      // last 1=allow varying read & write size
			&& file.file_read(&gameFile, sizeof(GameFile))
			&& gameFile.validate_header() )
		{
			strcpy( gameFile.file_name, file.file_name );  // in case that the name may be different
			gameFile.file_date = gameDir[i]->time;
	      linkin(&gameFile);
		}
		file.file_close();
	}
	// ##### end Gilbert 26/5 ######//
}
Пример #2
0
//-------- Begin of function GameFileArray::load_all_game_header --------//
//
// Load all headers of all saved game files in current directory.
//
void GameFileArray::load_all_game_header(const char *extStr)
{
	char full_path[MAX_PATH+1];
	int       i;
	Directory gameDir;
	GameFile  gameFile;
	File      file;

	if (!misc.path_cat(full_path, sys.dir_config, extStr, MAX_PATH))
	{
		ERR("Path to the config directory too long.\n");
		return;
	}
	gameDir.read(full_path, 0);  // 0-Don't sort file names

	//-------- read in the headers of all game sets -------//

	zap();

	for( i=1 ; i<=gameDir.size() ; i++ )
	{
		if (!misc.path_cat(full_path, sys.dir_config, gameDir[i]->name, MAX_PATH))
		{
			ERR("Path to the saved game too long.\n");
			continue;
		}
		if( file.file_open(full_path, 1, 1)      // last 1=allow varying read & write size
			&& file.file_read(&gameFile, sizeof(GameFile))
			&& gameFile.validate_header() )
		{
			strcpy( gameFile.file_name, gameDir[i]->name );  // in case that the name may be different
			gameFile.file_date = gameDir[i]->time;
	      linkin(&gameFile);
		}
		file.file_close();
	}

	quick_sort( sort_game_file_function );
}