Skip to content

Commit

Permalink
Merge pull request #1108 from ps2homebrew/fixWrongReaddirUsage
Browse files Browse the repository at this point in the history
Remove references from dirent->d_stat
  • Loading branch information
AKuHAK authored Dec 2, 2023
2 parents 513e9b3 + 594d7de commit a7df578
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 a7df578

Please sign in to comment.