Lib: fix bug for apps built with VS2015 running on WinXP

for boinc_file_exists(), use GetFileAttributesA().
_stat64() doesn't work in this case
This commit is contained in:
David Anderson 2017-01-31 14:55:38 -08:00
parent 624595267c
commit bbd34f70d3
1 changed files with 9 additions and 5 deletions

View File

@ -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
//