Exemplo n.º 1
0
s32 __Menu_GetEntries(void)
{
	struct discHdr *buffer = NULL;

	u32 cnt, len;
	s32 ret;

	/* Get list length */
	ret = WBFS_GetCount(&cnt);
	if (ret < 0)
		return ret;

	/* Buffer length */
	len = sizeof(struct discHdr) * cnt;

	/* Allocate memory */
	buffer = (struct discHdr *)memalign(32, len);
	if (!buffer)
		return -1;

	/* Clear buffer */
	memset(buffer, 0, len);

	/* Get header list */
	ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
	if (ret < 0)
		goto err;

	/* Sort entries */
	qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);

	/* Free memory */
	if (gameList)
		free(gameList);

	/* Set values */
	gameList = buffer;
	gameCnt  = cnt;

	/* Reset variables */
	gameSelected = gameStart = 0;

	return 0;

err:
	/* Free memory */
	if (buffer)
		free(buffer);

	return ret;
}
Exemplo n.º 2
0
void Save_Game_List()
{
	struct discHdr *buffer = NULL;
	u32 cnt, len;
	s32 ret;
	char name[200];
	FILE *f;
	int i;

	// Get Game List
	ret = WBFS_GetCount(&cnt);
	if (ret < 0) return;

	printf_x(gt("Saving gamelist.txt ... "));
	__console_flush(0);

	len = sizeof(struct discHdr) * cnt;
	buffer = (struct discHdr *)memalign(32, len);
	if (!buffer) goto error;
	memset(buffer, 0, len);
	ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
	if (ret < 0) goto error;

	snprintf(D_S(name), "%s/%s", USBLOADER_PATH, "gamelist.txt");
	f = fopen(name, "wb");
	if (!f) goto error;
	fprintf(f, "# CFG USB Loader game list %s\n", CFG_VERSION);
	for (i=0; i<gameCnt; i++) {
		fprintf(f, "# %.6s %s\n", gameList[i].id, gameList[i].title);
		fprintf(f, "%.6s = %s\n", gameList[i].id, get_title(&gameList[i]));
	}
	fclose(f);
	SAFE_FREE(buffer);
	printf("OK");
	return;

	error:
	SAFE_FREE(buffer);
	printf(gt("ERROR"));
}
Exemplo n.º 3
0
s32 __Menu_GetEntries(void)
{
	struct discHdr *buffer = NULL;

	u32 cnt, len;
	s32 ret;

	Cache_Invalidate();

	Switch_Favorites(false);
	SAFE_FREE(fav_gameList);
	fav_gameCnt = 0;
	
	
	SAFE_FREE(filter_gameList);
	filter_gameCnt = 0;

	/* Get list length */
	ret = WBFS_GetCount(&cnt);
	if (ret < 0)
		return ret;

	/* Buffer length */
	len = sizeof(struct discHdr) * cnt;

	/* Allocate memory */
	buffer = (struct discHdr *)memalign(32, len);
	if (!buffer)
		return -1;

	/* Clear buffer */
	memset(buffer, 0, len);

	/* Get header list */
	ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
	if (ret < 0)
		goto err;

	/* Sort entries */
	__set_default_sort();
	qsort(buffer, cnt, sizeof(struct discHdr), default_sort_function);

	// hide and re-sort preffered
	if (!CFG.admin_lock || CFG.admin_mode_locked)
		cnt = CFG_hide_games(buffer, cnt);
	CFG_sort_pref(buffer, cnt);

	/* Free memory */
	if (gameList)
		free(gameList);

	/* Set values */
	gameList = buffer;
	gameCnt  = cnt;

	/* Reset variables */
	gameSelected = gameStart = 0;

	// init favorites
	all_gameList = gameList;
	all_gameCnt  = gameCnt;
	len = sizeof(struct discHdr) * all_gameCnt;
	fav_gameList = (struct discHdr *)memalign(32, len);
	if (fav_gameList) {
		memcpy(fav_gameList, all_gameList, len);
		fav_gameCnt = all_gameCnt;
	}
	
	filter_gameList = (struct discHdr *)memalign(32, len);
	if (filter_gameList) {
		memcpy(filter_gameList, all_gameList, len);
		filter_gameCnt = all_gameCnt;
	}

	return 0;

err:
	/* Free memory */
	if (buffer)
		free(buffer);

	return ret;
}