From 6cb795ef7d86f14358f2b497c561de1c226465c4 Mon Sep 17 00:00:00 2001 From: greye Date: Mon, 19 May 2014 10:47:02 +0400 Subject: [PATCH] attempt to fix LowLevelFile, minor code reuse --- components/files/lowlevelfile.cpp | 5 ++++- components/settings/settings.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/components/files/lowlevelfile.cpp b/components/files/lowlevelfile.cpp index 06ee9fb4e..4466e354d 100644 --- a/components/files/lowlevelfile.cpp +++ b/components/files/lowlevelfile.cpp @@ -206,6 +206,8 @@ size_t LowLevelFile::read (void * data, size_t size) } #elif FILE_API == FILE_API_WIN32 + +#include /* * * Implementation of LowLevelFile methods using Win32 API calls @@ -227,7 +229,8 @@ void LowLevelFile::open (char const * filename) { assert (mHandle == INVALID_HANDLE_VALUE); - HANDLE handle = CreateFileA (filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + std::wstring wname = boost::locale::conv::utf_to_utf(filename); + HANDLE handle = CreateFileW (wname.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (handle == NULL) { diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 56e937c8e..0def0afdb 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -8,6 +8,8 @@ #include #include +#include + using namespace Settings; namespace bfs = boost::filesystem; @@ -19,15 +21,13 @@ CategorySettingValueMap Manager::mNewSettings = CategorySettingValueMap(); void Manager::loadUser (const std::string& file) { - bfs::ifstream fin((bfs::path(file))); - Ogre::DataStreamPtr stream((OGRE_NEW Ogre::FileStreamDataStream(file, &fin, false))); + Ogre::DataStreamPtr stream = openConstrainedFileDataStream(file.c_str()); mFile.load(stream); } void Manager::loadDefault (const std::string& file) { - bfs::ifstream fin((bfs::path(file))); - Ogre::DataStreamPtr stream((OGRE_NEW Ogre::FileStreamDataStream(file, &fin, false))); + Ogre::DataStreamPtr stream = openConstrainedFileDataStream(file.c_str()); mDefaultFile.load(stream); }