Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
Revert "Revert "Remove references from dirent->d_stat""
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy authored and citronalco committed Aug 8, 2024
1 parent 6306c1b commit a1f5da5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/supportbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static int scanForISO(char *path, char type, struct game_list_t **glist)
char fullpath[256], startup[GAME_STARTUP_MAX];
struct dirent *dirent;
DIR *dir;
struct stat statbuf;

cache.games = NULL;
cache.count = 0;
Expand All @@ -302,6 +303,8 @@ static int scanForISO(char *path, char type, struct game_list_t **glist)
if (NameLen > ISO_GAME_NAME_MAX)
continue; // Skip files that cannot be supported properly.

snprintf(fullpath, sizeof(fullpath), "%s/%s", path, dirent->d_name);

if (format == GAME_FORMAT_OLD_ISO) {
struct game_list_t *next = (struct game_list_t *)malloc(sizeof(struct game_list_t));

Expand All @@ -324,8 +327,6 @@ static int scanForISO(char *path, char type, struct game_list_t **glist)
}
} else {
if (queryISOGameListCache(&cache, &cachedGInfo, dirent->d_name) != 0) {
snprintf(fullpath, sizeof(fullpath), "%s/%s", path, dirent->d_name);

if ((MountFD = fileXioMount("iso:", fullpath, FIO_MT_RDONLY)) >= 0) {
if (GetStartupExecName("iso:/SYSTEM.CNF;1", startup, GAME_STARTUP_MAX - 1) == 0) {
struct game_list_t *next = (struct game_list_t *)malloc(sizeof(struct game_list_t));
Expand Down Expand Up @@ -378,7 +379,12 @@ static int scanForISO(char *path, char type, struct game_list_t **glist)
game->parts = 1;
game->media = type;
game->format = format;
game->sizeMB = dirent->d_stat.st_size >> 20;

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

count++;
}
Expand Down

0 comments on commit a1f5da5

Please sign in to comment.