1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-31 04:36:40 +00:00

Fix build errors after rebase against master due to large amount of changes.

This commit is contained in:
Project579 2022-07-28 22:20:44 +02:00
parent c3175e371a
commit 2df8bfed25
13 changed files with 36 additions and 23 deletions

View file

@ -260,7 +260,7 @@ void Bsa::BSAFile::close()
Files::IStreamPtr Bsa::BSAFile::getFile(const FileStruct *file)
{
return Files::openConstrainedFileStream(mFilename, file->offset, file->fileSize);
return Files::openConstrainedFileStream(mFilepath, file->offset, file->fileSize);
}
void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)

View file

@ -11,7 +11,7 @@ namespace Files
ConstrainedFileStreamBuf::ConstrainedFileStreamBuf(const std::filesystem::path& fname, std::size_t start, std::size_t length)
: mOrigin(start)
{
mFile = File::open(fname.c_str());
mFile = File::open(fname);
mSize = length != std::numeric_limits<std::size_t>::max() ? length : File::size(mFile) - start;
if (start != 0)

View file

@ -1,9 +1,10 @@
#ifndef OPENMW_CONSTRAINEDFILESTREAMBUF_H
#define OPENMW_CONSTRAINEDFILESTREAMBUF_H
#include <components/platform/file.hpp>
#include <streambuf>
#include <filesystem>
#include <components/platform/file.hpp>
namespace Files
{

View file

@ -1,6 +1,5 @@
#include "myguidatamanager.hpp"
#include <memory>
#include <string>
#include <stdexcept>
@ -40,7 +39,7 @@ DataManager::DataManager(const std::string& resourcePath, const VFS::Manager* vf
MyGUI::IDataStream *DataManager::getData(const std::string &name) const
{
return new DataStream(mVfs->get(mResourcePath / name));
return new DataStream(mVfs->get(Files::pathToUnicodeString(mResourcePath / name)));
}
void DataManager::freeData(MyGUI::IDataStream *data)
@ -50,7 +49,7 @@ void DataManager::freeData(MyGUI::IDataStream *data)
bool DataManager::isDataExist(const std::string &name) const
{
return mVfs->exists(mResourcePath / name);
return mVfs->exists(Files::pathToUnicodeString(mResourcePath / name));
}
const MyGUI::VectorString &DataManager::getDataListNames(const std::string &pattern) const
@ -63,8 +62,10 @@ const std::string &DataManager::getDataPath(const std::string &name) const
static std::string result;
result.clear();
if (name.empty())
return mResourcePath;
if (name.empty()) {
result = Files::pathToUnicodeString(mResourcePath);
return result;
}
if (!isDataExist(name))
return result;

View file

@ -4,6 +4,8 @@
#include "myguidatamanager.hpp"
#include "myguiloglistener.hpp"
#include "components/files/conversion.hpp"
namespace osgMyGUI
{
@ -11,7 +13,7 @@ Platform::Platform(osgViewer::Viewer *viewer, osg::Group* guiRoot, Resource::Ima
const VFS::Manager* vfs, float uiScalingFactor, const std::filesystem::path& resourcePath, const std::filesystem::path& logName)
: mLogFacility(logName.empty() ? nullptr : std::make_unique<LogFacility>(logName, false))
, mLogManager(std::make_unique<MyGUI::LogManager>())
, mDataManager(std::make_unique<DataManager>(resourcePath, vfs))
, mDataManager(std::make_unique<DataManager>(Files::pathToUnicodeString(resourcePath), vfs))
, mRenderManager(std::make_unique<RenderManager>(viewer, guiRoot, imageManager, uiScalingFactor))
{
if (mLogFacility != nullptr)

View file

@ -2,6 +2,7 @@
#include <components/debug/debuglog.hpp>
#include <components/files/hash.hpp>
#include <components/files/conversion.hpp>
#include <algorithm>
#include <array>
@ -373,7 +374,7 @@ void NIFFile::warn(const std::string &msg) const
[[noreturn]] void NIFFile::fail(const std::string &msg) const
{
throw std::runtime_error(" NIFFile Error: " + msg + "\nFile: " + filename);
throw std::runtime_error(" NIFFile Error: " + msg + "\nFile: " + Files::pathToUnicodeString(filename));
}
std::string NIFFile::getString(uint32_t index) const

View file

@ -5,6 +5,7 @@
#include <vector>
#include <atomic>
#include <filesystem>
#include <components/files/istreamptr.hpp>

View file

@ -2,7 +2,7 @@
#define OPENMW_COMPONENTS_PLATFORM_FILE_HPP
#include <cstdlib>
#include <string_view>
#include <filesystem>
namespace Platform::File {
@ -18,7 +18,7 @@ namespace Platform::File {
End
};
Handle open(const char* filename);
Handle open(const std::filesystem::path& filename);
void close(Handle handle);

View file

@ -9,6 +9,8 @@
#include <string>
#include <cassert>
#include <components/files/conversion.hpp>
namespace Platform::File {
static auto getNativeHandle(Handle handle)
@ -29,7 +31,7 @@ namespace Platform::File {
return -1;
}
Handle open(const char* filename)
Handle open(const std::filesystem::path& filename)
{
#ifdef O_BINARY
static const int openFlags = O_RDONLY | O_BINARY;
@ -37,10 +39,10 @@ namespace Platform::File {
static const int openFlags = O_RDONLY;
#endif
auto handle = ::open(filename, openFlags, 0);
auto handle = ::open(filename.c_str(), openFlags, 0);
if (handle == -1)
{
throw std::runtime_error(std::string("Failed to open '") + filename + "' for reading: " + strerror(errno));
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename) + "' for reading: " + strerror(errno));
}
return static_cast<Handle>(handle);
}

View file

@ -6,6 +6,8 @@
#include <stdexcept>
#include <cassert>
#include <components/files/conversion.hpp>
namespace Platform::File {
static auto getNativeHandle(Handle handle)
@ -26,12 +28,12 @@ namespace Platform::File {
return -1;
}
Handle open(const char* filename)
Handle open(const std::filesystem::path& filename)
{
FILE* handle = fopen(filename, "rb");
FILE* handle = fopen(filename.c_str(), "rb");
if (handle == nullptr)
{
throw std::runtime_error(std::string("Failed to open '") + filename + "' for reading: " + strerror(errno));
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename) + "' for reading: " + strerror(errno));
}
return static_cast<Handle>(reinterpret_cast<intptr_t>(handle));
}

View file

@ -6,6 +6,8 @@
#include <boost/locale.hpp>
#include <cassert>
#include <components/files/conversion.hpp>
namespace Platform::File {
static auto getNativeHandle(Handle handle)
@ -26,13 +28,12 @@ namespace Platform::File {
return -1;
}
Handle open(const char* filename)
Handle open(const std::filesystem::path& filename)
{
std::wstring wname = boost::locale::conv::utf_to_utf<wchar_t>(filename);
HANDLE handle = CreateFileW(wname.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
HANDLE handle = CreateFileW(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
{
throw std::runtime_error(std::string("Failed to open '") + filename + "' for reading: " + std::to_string(GetLastError()));
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename) + "' for reading: " + std::to_string(GetLastError()));
}
return static_cast<Handle>(reinterpret_cast<intptr_t>(handle));
}

View file

@ -2,6 +2,7 @@
#define OPENMW_COMPONENTS_RESOURCE_ARCHIVE_H
#include <map>
#include <filesystem>
#include <components/files/istreamptr.hpp>

View file

@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <string>
#include <filesystem>
namespace VFS
{