From 9c7967c662e1ceb553bc75cbdacf95961578ff01 Mon Sep 17 00:00:00 2001 From: KrahJohlito Date: Fri, 20 Dec 2024 09:41:29 +1030 Subject: [PATCH] test get size at cfg pop --- src/supportbase.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/supportbase.c b/src/supportbase.c index fac789a49..c2584c7f6 100644 --- a/src/supportbase.c +++ b/src/supportbase.c @@ -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] = '/'; @@ -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++; } @@ -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);