From a99183e4251f9c4cc2637342ee2c57d993ce0aab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Oct 2015 03:04:23 +0200 Subject: [PATCH] (Windows) Attempt implementing reading the file size without relying on stat --- libretro-common/file/retro_stat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libretro-common/file/retro_stat.c b/libretro-common/file/retro_stat.c index d3a2664148..ad5008889a 100644 --- a/libretro-common/file/retro_stat.c +++ b/libretro-common/file/retro_stat.c @@ -100,20 +100,23 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size) if (cellFsStat(path, &buf) < 0) return false; #elif defined(_WIN32) - struct stat buf; - DWORD ret = GetFileAttributes(path); + WIN32_FILE_ATTRIBUTE_DATA file_info; + DWORD ret = GetFileAttributes(path, 0, &file_info); if (ret == INVALID_FILE_ATTRIBUTES) return false; - if (stat(path, &buf) < 0) - return false; #else struct stat buf; if (stat(path, &buf) < 0) return false; #endif +#if defined(_WIN32) + if (size) + *size = file_info.nFileSizeLow; +#else if (size) *size = buf.st_size; +#endif switch (mode) {