diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index f5f13afe0..f414037c2 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -90,7 +90,7 @@ struct FStreamWrapper { public: bool Open(const char *path, std::ios::openmode mode) { - s_ = std::make_unique(path, mode); + s_ = CreateFileStream(path, mode); return CheckError("new std::fstream(\"%s\", %s)", path, OpenModeToString(mode).c_str()); } diff --git a/Source/utils/file_util.cpp b/Source/utils/file_util.cpp index 75b1b73fb..46409fc8d 100644 --- a/Source/utils/file_util.cpp +++ b/Source/utils/file_util.cpp @@ -156,4 +156,9 @@ void RemoveFile(const char *lpFileName) #endif } +std::unique_ptr CreateFileStream(const char *path, std::ios::openmode mode) +{ + return std::make_unique(path, mode); +} + } // namespace devilution diff --git a/Source/utils/file_util.h b/Source/utils/file_util.h index 61b3a9320..555c3fa9c 100644 --- a/Source/utils/file_util.h +++ b/Source/utils/file_util.h @@ -1,11 +1,14 @@ #pragma once #include +#include +#include namespace devilution { bool FileExists(const char *path); bool GetFileSize(const char *path, std::uintmax_t *size); bool ResizeFile(const char *path, std::uintmax_t size); void RemoveFile(const char *lpFileName); +std::unique_ptr CreateFileStream(const char *path, std::ios::openmode mode); } // namespace devilution