Skip to content

Commit

Permalink
test get size at cfg pop
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito committed Dec 20, 2024
1 parent bfa5366 commit 9c7967c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/supportbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ static int scanForISO(char *path, char type, struct game_list_t **glist)
int cacheLoaded = loadISOGameListCache(path, &cache) == 0;

if ((dir = opendir(path)) != NULL) {
struct stat statbuf;

size_t base_path_len = strlen(path);
strcpy(fullpath, path);
fullpath[base_path_len] = '/';
Expand Down Expand Up @@ -363,13 +361,7 @@ static int scanForISO(char *path, char type, struct game_list_t **glist)
game->parts = 1;
game->media = type;
game->format = format;


if (stat(fullpath, &statbuf) == 0) {
game->sizeMB = statbuf.st_size >> 20;
} else {
game->sizeMB = 0;
}
game->sizeMB = 0;

count++;
}
Expand Down Expand Up @@ -773,10 +765,24 @@ void sbRename(base_game_info_t **list, const char *prefix, const char *sep, int
config_set_t *sbPopulateConfig(base_game_info_t *game, const char *prefix, const char *sep)
{
char path[256];
struct stat st;

snprintf(path, sizeof(path), "%sCFG%s%s.cfg", prefix, sep, game->startup);
config_set_t *config = configAlloc(0, NULL, path);
configRead(config); // Does not matter if the config file could be loaded or not.

// Get game size if not already set
if ((game->sizeMB == 0) && (game->format != GAME_FORMAT_OLD_ISO)) {
char gamepath[256];

snprintf(gamepath, sizeof(gamepath), "%s%s%s%s%s%s", prefix, sep, game->media == SCECdPS2CD ? "CD" : "DVD", sep, game->name, game->extension);

if (stat(gamepath, &st) == 0)
game->sizeMB = st.st_size >> 20;
else
game->sizeMB = 0;
}

configSetStr(config, CONFIG_ITEM_NAME, game->name);
configSetInt(config, CONFIG_ITEM_SIZE, game->sizeMB);

Expand Down

0 comments on commit 9c7967c

Please sign in to comment.