|
|
|
|
@ -1,12 +1,11 @@
|
|
|
|
|
#include "utils/file_util.h" |
|
|
|
|
#include "utils/log.hpp" |
|
|
|
|
|
|
|
|
|
#include <algorithm> |
|
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
|
#include <SDL.h> |
|
|
|
|
|
|
|
|
|
#include "utils/stdcompat/string_view.hpp" |
|
|
|
|
#include "utils/log.hpp" |
|
|
|
|
|
|
|
|
|
#ifdef USE_SDL1 |
|
|
|
|
#include "utils/sdl2_to_1_2_backports.h" |
|
|
|
|
@ -31,12 +30,8 @@
|
|
|
|
|
#include <cstdio> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#include "storm/storm.h" |
|
|
|
|
|
|
|
|
|
namespace devilution { |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
#if defined(_WIN64) || defined(_WIN32) |
|
|
|
|
std::unique_ptr<wchar_t[]> ToWideChar(string_view path) |
|
|
|
|
{ |
|
|
|
|
@ -52,8 +47,6 @@ std::unique_ptr<wchar_t[]> ToWideChar(string_view path)
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
bool FileExists(const char *path) |
|
|
|
|
{ |
|
|
|
|
#if defined(_WIN64) || defined(_WIN32) |
|
|
|
|
@ -172,18 +165,4 @@ std::unique_ptr<std::fstream> CreateFileStream(const char *path, std::ios::openm
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SFileOpenArchiveDiablo(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE *phMpq) |
|
|
|
|
{ |
|
|
|
|
#if defined(_WIN64) || defined(_WIN32) |
|
|
|
|
const auto szMpqNameUtf16 = ToWideChar(szMpqName); |
|
|
|
|
if (szMpqNameUtf16 == nullptr) { |
|
|
|
|
LogError("UTF-8 -> UTF-16 conversion error code {}", ::GetLastError()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return SFileOpenArchive(szMpqNameUtf16.get(), dwPriority, dwFlags, phMpq); |
|
|
|
|
#else |
|
|
|
|
return SFileOpenArchive(szMpqName, dwPriority, dwFlags, phMpq); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace devilution
|
|
|
|
|
|