Browse Source

Move creation of file stream to new helper CreateFileStream

pull/1925/head
obligaron 5 years ago committed by Anders Jenbo
parent
commit
a64f94d580
  1. 2
      Source/mpqapi.cpp
  2. 5
      Source/utils/file_util.cpp
  3. 3
      Source/utils/file_util.h

2
Source/mpqapi.cpp

@ -90,7 +90,7 @@ struct FStreamWrapper {
public:
bool Open(const char *path, std::ios::openmode mode)
{
s_ = std::make_unique<std::fstream>(path, mode);
s_ = CreateFileStream(path, mode);
return CheckError("new std::fstream(\"%s\", %s)", path, OpenModeToString(mode).c_str());
}

5
Source/utils/file_util.cpp

@ -156,4 +156,9 @@ void RemoveFile(const char *lpFileName)
#endif
}
std::unique_ptr<std::fstream> CreateFileStream(const char *path, std::ios::openmode mode)
{
return std::make_unique<std::fstream>(path, mode);
}
} // namespace devilution

3
Source/utils/file_util.h

@ -1,11 +1,14 @@
#pragma once
#include <cstdint>
#include <fstream>
#include <memory>
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<std::fstream> CreateFileStream(const char *path, std::ios::openmode mode);
} // namespace devilution

Loading…
Cancel
Save