From 9539cf2a41050a66517996e6d8c5902a2fd7df58 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 22 Sep 2021 21:09:38 -0400 Subject: [PATCH] Use `fl_stat` for better Windows UTF-16 compatibility --- src/utils.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index f70ca93..2cf7bc9 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -47,21 +47,18 @@ bool file_exists(const char *f) { } size_t file_size(const char *f) { -#ifdef __CYGWIN__ -#define stat64 stat -#elif defined(_WIN32) -#define stat64 _stat32i64 -#endif - struct stat64 s; - int r = stat64(f, &s); + struct stat s; + int r = fl_stat(f, &s); return r ? 0 : (size_t)s.st_size; } size_t file_size(FILE *f) { #ifdef __CYGWIN__ +#define stat64 stat #define fstat64 fstat #elif defined(_WIN32) #define fileno _fileno +#define stat64 _stat32i64 #define fstat64 _fstat32i64 #endif struct stat64 s;