| 119 | #if defined(_WIN64) || defined(_WIN32) |
| 120 | namespace { |
| 121 | DWORD WindowsGetFileAttributes(const char *path) |
| 122 | { |
| 123 | #if defined(NXDK) |
| 124 | const DWORD attr = ::GetFileAttributesA(path); |
| 125 | #else |
| 126 | const auto pathUtf16 = ToWideChar(path); |
| 127 | if (pathUtf16 == nullptr) { |
| 128 | LogError("UTF-8 -> UTF-16 conversion error code {}", ::GetLastError()); |
| 129 | return false; |
| 130 | } |
| 131 | const DWORD attr = ::GetFileAttributesW(&pathUtf16[0]); |
| 132 | #endif |
| 133 | if (attr == INVALID_FILE_ATTRIBUTES) { |
| 134 | if (::GetLastError() == ERROR_FILE_NOT_FOUND || ::GetLastError() == ERROR_PATH_NOT_FOUND) { |
| 135 | ::SetLastError(ERROR_SUCCESS); |
| 136 | } else { |
| 137 | #if defined(NXDK) |
| 138 | LogError("GetFileAttributesA: error code {}", ::GetLastError()); |
| 139 | #else |
| 140 | LogError("GetFileAttributesW: error code {}", ::GetLastError()); |
| 141 | #endif |
| 142 | } |
| 143 | } |
| 144 | return attr; |
| 145 | } |
| 146 | } // namespace |
| 147 | |
| 148 | #endif |
no test coverage detected