Skip to content

Commit

Permalink
Utility: ah nice, Xcode 11.5 has the S_ISDIR() iOS bug inverted.
Browse files Browse the repository at this point in the history
Who would expect that upgrading to a next minor version of Xcode is such
a pain. It's the most expensive platform of them all, AND YET
  • Loading branch information
mosra committed May 24, 2022
1 parent bbcad06 commit 5af4056
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Corrade/Utility/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,18 @@ namespace {
append(), copy() destination or map() / mapWrite), there the opening itself fails already. On Windows, opening directories fails in any case, so there
we don't need to do anything either. */
bool isDirectory(const int fd) {
#ifdef CORRADE_TARGET_IOS
/* iOS used to return false for S_ISDIR() since Xcode 7.3 and including
11.4, but as of Xcode 11.5, it returns true. Which is a totally crappy
behavior, so we just return false always. Might be a simulator-specific
bug, but as there's no official documented way to detect a simulator, I
won't even bother. */
static_cast<void>(fd);
return false;
#else
struct stat st;
return fstat(fd, &st) == 0 && S_ISDIR(st.st_mode);
#endif
}
#endif

Expand All @@ -275,7 +285,14 @@ bool isDirectory(const Containers::StringView path) {
/** @todo symlink support */
const DWORD fileAttributes = GetFileAttributesW(Unicode::widen(path));
return fileAttributes != INVALID_FILE_ATTRIBUTES && (fileAttributes & FILE_ATTRIBUTE_DIRECTORY);

#elif defined(CORRADE_TARGET_IOS)
/* iOS used to return false for S_ISDIR() since Xcode 7.3 and including
11.4, but as of Xcode 11.5, it returns true. Which is a totally crappy
behavior, so we just return false always. Might be a simulator-specific
bug, but as there's no official documented way to detect a simulator, I
won't even bother. */
static_cast<void>(path);
return false;
#elif defined(CORRADE_TARGET_UNIX) || defined(CORRADE_TARGET_EMSCRIPTEN)
/* using stat() instead of lstat() as that follows symlinks and that's what
is desired in most cases */
Expand Down

0 comments on commit 5af4056

Please sign in to comment.