From faf6454c26604863557030428a51a146aa04d663 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 | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/supportbase.c b/src/supportbase.c index fac789a49..242f0a758 100644 --- a/src/supportbase.c +++ b/src/supportbase.c @@ -304,7 +304,7 @@ 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; + //struct stat statbuf; size_t base_path_len = strlen(path); strcpy(fullpath, path); @@ -365,11 +365,10 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) game->format = format; - if (stat(fullpath, &statbuf) == 0) { + /*if (stat(fullpath, &statbuf) == 0) { game->sizeMB = statbuf.st_size >> 20; - } else { - game->sizeMB = 0; - } + } else {*/ + game->sizeMB = 0; count++; } @@ -773,10 +772,28 @@ 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. + char gamepath[256]; + // Get game size if not already set + if (game->sizeMB == 0) { + if (game->format == GAME_FORMAT_OLD_ISO) + snprintf(gamepath, sizeof(gamepath), "%s%s%s%s%s%s", prefix, sep, game->media == SCECdPS2CD ? "CD" : "DVD", sep, game->startup, game->extension); + else + 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; + } + + LOG("GAMEPATH=%s\n", gamepath); + configSetStr(config, CONFIG_ITEM_NAME, game->name); configSetInt(config, CONFIG_ITEM_SIZE, game->sizeMB); @@ -789,7 +806,6 @@ config_set_t *sbPopulateConfig(base_game_info_t *game, const char *prefix, const configSetStr(config, CONFIG_ITEM_FORMAT, "UL"); configSetStr(config, CONFIG_ITEM_MEDIA, game->media == SCECdPS2CD ? "CD" : "DVD"); - configSetStr(config, CONFIG_ITEM_STARTUP, game->startup); return config;