Need to use boost::filesystem::path to open UTF-8-aware file streams.

This commit is contained in:
WrinklyNinja
2013-07-22 19:09:43 +01:00
parent 78fe61bdc0
commit d8e16669be
8 changed files with 42 additions and 7 deletions
+2
View File
@@ -13,6 +13,8 @@ project (boss)
set (BOSS_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata.cpp" "${CMAKE_SOURCE_DIR}/src/backend/game.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers.cpp" "${CMAKE_SOURCE_DIR}/src/backend/network.cpp" "${CMAKE_SOURCE_DIR}/src/backend/globals.cpp" "${PROJECT_LIBS_DIR}/pugixml/src/pugixml.cpp")
set (BOSS_SRC ${BOSS_SRC} "${PROJECT_LIBS_DIR}/boost/libs/iostreams/src/file_descriptor.cpp")
# Include source and library directories.
include_directories ("${PROJECT_LIBS_DIR}/alphanum" "${PROJECT_LIBS_DIR}/boost" "${PROJECT_LIBS_DIR}/yaml-cpp/include" "${CMAKE_SOURCE_DIR}/src" "${PROJECT_LIBS_DIR}/libloadorder/src" "${PROJECT_LIBS_DIR}/libespm" "${PROJECT_LIBS_DIR}/zlib" "${PROJECT_LIBS_DIR}/pugixml/src" "${PROJECT_LIBS_DIR}/wxWidgets/include")
+1
View File
@@ -101,6 +101,7 @@ Follow the instructions in libloadorder's README to build it as a static library
### BOSS
```
mkdir build
cd build
cmake .. -DPROJECT_LIBS_DIR=.. -DPROJECT_ARCH=32 -DPROJECT_LINK=STATIC -DCMAKE_TOOLCHAIN_FILE=mingw-toolchain.cmake
make
+1 -1
View File
@@ -591,7 +591,7 @@ BOSS_API unsigned int boss_write_minimal_list (boss_db db, const char * const ou
<< YAML::Key << "plugins" << YAML::Value << temp
<< YAML::EndMap;
boss::ofstream out(outputFile);
boss::ofstream out(boost::filesystem::path(outputFile));
if (out.fail())
return boss_error_invalid_args;
out << yout.c_str();
+2 -1
View File
@@ -35,6 +35,7 @@
#include <string>
#include <list>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
namespace boss {
@@ -509,7 +510,7 @@ namespace boss {
yout.SetIndent(2);
yout << root;
boss::ofstream out(file.c_str());
boss::ofstream out(boost::filesystem::path(file));
out << yout.c_str();
out.close();
}
+1 -1
View File
@@ -125,7 +125,7 @@ namespace boss {
uint32_t chksum = 0;
static const size_t buffer_size = 8192;
char buffer[buffer_size];
boss::ifstream ifile(filename.string().c_str(), ios::binary);
boss::ifstream ifile(filename, ios::binary);
// LOG_TRACE("calculating CRC for: '%s'", filename.string().c_str());
boost::crc_32_type result;
if (ifile) {
+31
View File
@@ -0,0 +1,31 @@
/* BOSS
A plugin load order optimiser for games that use the esp/esm plugin system.
Copyright (C) 2012 WrinklyNinja
This file is part of BOSS.
BOSS is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
BOSS is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BOSS. If not, see
<http://www.gnu.org/licenses/>.
*/
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
namespace boss {
typedef boost::iostreams::stream< boost::iostreams::file_descriptor_sink > ofstream;
typedef boost::iostreams::stream< boost::iostreams::file_descriptor_source > ifstream;
typedef boost::iostreams::stream< boost::iostreams::file_descriptor > fstream;
}
+1 -1
View File
@@ -650,7 +650,7 @@ void Editor::OnQuit(wxCommandEvent& event) {
<< YAML::Key << "plugins" << YAML::Value << _editedPlugins
<< YAML::EndMap;
boss::ofstream out(_userlistPath.c_str());
boss::ofstream out(fs::path(_userlistPath));
out << yout.c_str();
out.close();
}
+3 -3
View File
@@ -377,7 +377,7 @@ void Launcher::OnClose(wxCloseEvent& event) {
yout.SetIndent(2);
yout << _settings;
boss::ofstream out(boss::g_path_settings.string().c_str());
boss::ofstream out(boss::g_path_settings);
out << yout.c_str();
out.close();
@@ -653,7 +653,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
<< YAML::Key << "plugins" << YAML::Value << ulist_plugins
<< YAML::EndMap;
boss::ofstream uout(_game.UserlistPath().string().c_str());
boss::ofstream uout(_game.UserlistPath());
uout << yout.c_str();
uout.close();
@@ -687,7 +687,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
if (fs::exists(_game.ReportPath().string())) {
BOOST_LOG_TRIVIAL(debug) << "Reading the previous report's details section.";
//Read the whole file in.
boss::ifstream in(_game.ReportPath().string().c_str(), ios::binary);
boss::ifstream in(_game.ReportPath(), ios::binary);
in.seekg(0, std::ios::end);
oldDetails.resize(in.tellg());
in.seekg(0, std::ios::beg);