From bbd34f70d315336310e82b8d651730f1913a2778 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 31 Jan 2017 14:55:38 -0800 Subject: [PATCH] Lib: fix bug for apps built with VS2015 running on WinXP for boinc_file_exists(), use GetFileAttributesA(). _stat64() doesn't work in this case --- lib/filesys.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/filesys.cpp b/lib/filesys.cpp index 463db44e0a..e638c4d0ce 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -526,19 +526,23 @@ FILE* boinc_fopen(const char* path, const char* mode) { return f; } - -int boinc_file_exists(const char* path) { #ifdef _WIN32 - struct __stat64 buf; - if (_stat64(path, &buf)) { +int boinc_file_exists(const char* path) { + // don't use _stat64 because it doesn't work with VS2015, XP client + DWORD dwAttrib = GetFileAttributesA(path); + return (dwAttrib != INVALID_FILE_ATTRIBUTES + && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) + ); +} #else +int boinc_file_exists(const char* path) { struct stat buf; if (stat(path, &buf)) { -#endif return false; // stat() returns zero on success } return true; } +#endif // same, but doesn't traverse symlinks //