| 2163 | } |
| 2164 | |
| 2165 | bool FileSystem::RemoveDirectoryRecursive(StringView path) |
| 2166 | { |
| 2167 | if (path.empty()) return false; |
| 2168 | |
| 2169 | #if defined(DEATH_TARGET_WINDOWS_RT) |
| 2170 | SmallVector<wchar_t, MAX_PATH + 1> pathW(DefaultInit, path.size() + 1); |
| 2171 | Utf8::ToUtf16(pathW.data(), std::int32_t(pathW.size()), path.data(), std::int32_t(path.size())); |
| 2172 | WIN32_FILE_ATTRIBUTE_DATA lpFileInfo; |
| 2173 | if (!::GetFileAttributesExFromAppW(pathW.data(), GetFileExInfoStandard, &lpFileInfo) || (lpFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { |
| 2174 | return false; |
| 2175 | } |
| 2176 | |
| 2177 | // Do not recursively delete through reparse points |
| 2178 | Array<wchar_t> absPath = Utf8::ToUtf16(GetAbsolutePath(path)); |
| 2179 | return DeleteDirectoryInternal(absPath, (lpFileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != FILE_ATTRIBUTE_REPARSE_POINT, 0); |
| 2180 | #elif defined(DEATH_TARGET_WINDOWS) |
| 2181 | SmallVector<wchar_t, MAX_PATH + 1> pathW(DefaultInit, path.size() + 1); |
| 2182 | Utf8::ToUtf16(pathW.data(), std::int32_t(pathW.size()), path.data(), std::int32_t(path.size())); |
| 2183 | const DWORD attrs = ::GetFileAttributesW(pathW.data()); |
| 2184 | if (attrs == INVALID_FILE_ATTRIBUTES || (attrs & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { |
| 2185 | return false; |
| 2186 | } |
| 2187 | |
| 2188 | // Do not recursively delete through reparse points |
| 2189 | Array<wchar_t> absPath = Utf8::ToUtf16(GetAbsolutePath(path)); |
| 2190 | return DeleteDirectoryInternal(absPath, (attrs & FILE_ATTRIBUTE_REPARSE_POINT) != FILE_ATTRIBUTE_REPARSE_POINT, 0); |
| 2191 | #else |
| 2192 | return DeleteDirectoryInternal(path); |
| 2193 | #endif |
| 2194 | } |
| 2195 | |
| 2196 | bool FileSystem::RemoveFile(StringView path) |
| 2197 | { |
nothing calls this directly
no test coverage detected