From 5fc32baadda3e8694731157de54dcfb378689d43 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 29 Dec 2012 17:21:33 +0300 Subject: Another possible fix for broken libs. --- src/utils/physfsrwops.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp index 67376d3dc..9ca3080a3 100644 --- a/src/utils/physfsrwops.cpp +++ b/src/utils/physfsrwops.cpp @@ -175,12 +175,21 @@ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *handle) return retval; } /* PHYSFSRWOPS_makeRWops */ -SDL_RWops *PHYSFSRWOPS_openRead(const char *fname) +#ifdef __APPLE__ +static bool checkFilePath(char *fname) { if (!fname || !*fname) - return nullptr; + return false; + if (!PHYSFS_exists(fname) || PHYSFS_isDirectory(fname)) + return false; + return true; +} +#endif + +SDL_RWops *PHYSFSRWOPS_openRead(const char *fname) +{ #ifdef __APPLE__ - if (!PHYSFS_exists(fname)) + if (!checkFilePath(fname)) return nullptr; #endif return create_rwops(PHYSFS_openRead(fname)); @@ -188,10 +197,8 @@ SDL_RWops *PHYSFSRWOPS_openRead(const char *fname) SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname) { - if (!fname || !*fname) - return nullptr; #ifdef __APPLE__ - if (!PHYSFS_exists(fname)) + if (!checkFilePath(fname)) return nullptr; #endif return create_rwops(PHYSFS_openWrite(fname)); @@ -199,10 +206,8 @@ SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname) SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname) { - if (!fname || !*fname) - return nullptr; #ifdef __APPLE__ - if (!PHYSFS_exists(fname)) + if (!checkFilePath(fname)) return nullptr; #endif return create_rwops(PHYSFS_openAppend(fname)); -- cgit v1.2.3-70-g09d2