Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix games larger than 2GB not showing in GameSwitcher #1459

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/common/utils/file.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define _LARGEFILE64_SOURCE

#include "file.h"

#include <ctype.h>
Expand All @@ -20,26 +22,26 @@

bool exists(const char *file_path)
{
struct stat buffer;
return stat(file_path, &buffer) == 0;
struct stat64 buffer;
return stat64(file_path, &buffer) == 0;
}

bool is_file(const char *file_path)
{
struct stat buffer;
return stat(file_path, &buffer) == 0 && S_ISREG(buffer.st_mode);
struct stat64 buffer;
return stat64(file_path, &buffer) == 0 && S_ISREG(buffer.st_mode);
}

bool is_dir(const char *file_path)
{
struct stat buffer;
return stat(file_path, &buffer) == 0 && S_ISDIR(buffer.st_mode);
struct stat64 buffer;
return stat64(file_path, &buffer) == 0 && S_ISDIR(buffer.st_mode);
}

bool file_isModified(const char *path, time_t *old_mtime)
{
struct stat file_stat;
if (stat(path, &file_stat) == 0 && file_stat.st_mtime > *old_mtime) {
struct stat64 file_stat;
if (stat64(path, &file_stat) == 0 && file_stat.st_mtime > *old_mtime) {
*old_mtime = file_stat.st_mtime;
return true;
}
Expand Down Expand Up @@ -342,7 +344,7 @@ bool file_findNewest(const char *dir_path, char *newest_file, size_t buffer_size
{
DIR *d;
struct dirent *dir;
struct stat file_stat;
struct stat64 file_stat;
time_t newest_mtime = 0;

d = opendir(dir_path);
Expand All @@ -356,7 +358,7 @@ bool file_findNewest(const char *dir_path, char *newest_file, size_t buffer_size
char full_path[PATH_MAX];
snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, dir->d_name);

if (stat(full_path, &file_stat) == 0) {
if (stat64(full_path, &file_stat) == 0) {
if (!found || file_stat.st_mtime > newest_mtime) {
newest_mtime = file_stat.st_mtime;
strncpy(newest_file, dir->d_name, buffer_size);
Expand Down
Loading