| 1662 | } |
| 1663 | |
| 1664 | bool FileSystem::IsReadable(StringView path) |
| 1665 | { |
| 1666 | if (path.empty()) return false; |
| 1667 | |
| 1668 | #if defined(DEATH_TARGET_WINDOWS_RT) |
| 1669 | SmallVector<wchar_t, MAX_PATH + 1> pathW(DefaultInit, path.size() + 1); |
| 1670 | Utf8::ToUtf16(pathW.data(), std::int32_t(pathW.size()), path.data(), std::int32_t(path.size())); |
| 1671 | WIN32_FILE_ATTRIBUTE_DATA lpFileInfo; |
| 1672 | return ::GetFileAttributesExFromAppW(pathW.data(), GetFileExInfoStandard, &lpFileInfo); |
| 1673 | #elif defined(DEATH_TARGET_WINDOWS) |
| 1674 | SmallVector<wchar_t, MAX_PATH + 1> pathW(DefaultInit, path.size() + 1); |
| 1675 | Utf8::ToUtf16(pathW.data(), std::int32_t(pathW.size()), path.data(), std::int32_t(path.size())); |
| 1676 | const DWORD attrs = ::GetFileAttributesW(pathW.data()); |
| 1677 | return (attrs != INVALID_FILE_ATTRIBUTES); |
| 1678 | #else |
| 1679 | auto nullTerminatedPath = String::nullTerminatedView(path); |
| 1680 | # if defined(DEATH_TARGET_ANDROID) |
| 1681 | if (auto strippedPath = AndroidAssetStream::TryGetAssetPath(nullTerminatedPath)) { |
| 1682 | return AndroidAssetStream::TryOpen(strippedPath); |
| 1683 | } |
| 1684 | # endif |
| 1685 | struct stat sb; |
| 1686 | if (::stat(nullTerminatedPath.data(), &sb) == 0) { |
| 1687 | return ((sb.st_mode & S_IRUSR) != 0); |
| 1688 | } |
| 1689 | return false; |
| 1690 | #endif |
| 1691 | } |
| 1692 | |
| 1693 | bool FileSystem::IsWritable(StringView path) |
| 1694 | { |