MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / DirectoryExists

Method DirectoryExists

Sources/Shared/IO/FileSystem.cpp:1584–1607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1582#endif
1583
1584 bool FileSystem::DirectoryExists(StringView path)
1585 {
1586 if (path.empty()) return false;
1587
1588#if defined(DEATH_TARGET_WINDOWS_RT)
1589 WIN32_FILE_ATTRIBUTE_DATA lpFileInfo;
1590 return (::GetFileAttributesExFromAppW(Utf8::ToUtf16(path), GetFileExInfoStandard, &lpFileInfo) && (lpFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
1591#elif defined(DEATH_TARGET_WINDOWS)
1592 const DWORD attrs = ::GetFileAttributesW(Utf8::ToUtf16(path));
1593 return (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
1594#else
1595 auto nullTerminatedPath = String::nullTerminatedView(path);
1596# if defined(DEATH_TARGET_ANDROID)
1597 if (auto strippedPath = AndroidAssetStream::TryGetAssetPath(nullTerminatedPath)) {
1598 return AndroidAssetStream::TryOpenDirectory(strippedPath);
1599 }
1600# endif
1601 struct stat sb;
1602 if (::stat(nullTerminatedPath.data(), &sb) == 0) {
1603 return ((sb.st_mode & S_IFMT) == S_IFDIR);
1604 }
1605 return false;
1606#endif
1607 }
1608
1609 bool FileSystem::FileExists(StringView path)
1610 {

Callers

nothing calls this directly

Calls 4

statClass · 0.70
ToUtf16Function · 0.50
emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected