mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Cleaner code & MSVC compatibility
This commit is contained in:
parent
1f4bc0f2e4
commit
f9b255c896
@ -71,6 +71,7 @@
|
||||
<Add option="-Wno-overloaded-virtual" />
|
||||
<Add option="-fpermissive" />
|
||||
<Add option="-DBOOST_THREAD_USE_LIB" />
|
||||
<Add option="-DBOOST_SYSTEM_NO_DEPRECATED" />
|
||||
<Add option="-D_WIN32_WINNT=0x0501" />
|
||||
<Add option="-D_WIN32" />
|
||||
<Add directory="$(#boost.include)" />
|
||||
|
@ -97,12 +97,7 @@ JsonNode toJson(QVariant object)
|
||||
|
||||
void JsonToFile(QString filename, QVariant object)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FileStream file(boost::filesystem::path(filename.toStdWString()), std::ios::out | std::ios_base::binary);
|
||||
#else
|
||||
FileStream file(boost::filesystem::path(filename.toUtf8().data()), std::ios::out | std::ios_base::binary);
|
||||
#endif
|
||||
|
||||
FileStream file(qstringToPath(filename), std::ios::out | std::ios_base::binary);
|
||||
file << toJson(object);
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ void CModManager::loadMods()
|
||||
ResourceID resID(CModInfo::getModFile(modname));
|
||||
if (CResourceHandler::get()->existsResource(resID))
|
||||
{
|
||||
boost::filesystem::path name = *CResourceHandler::get()->getResourceName(resID);
|
||||
auto mod = JsonUtils::JsonFromFile(QString::fromUtf8(name.string().c_str()));
|
||||
std::string name = *CResourceHandler::get()->getResourceName(resID);
|
||||
auto mod = JsonUtils::JsonFromFile(QString::fromUtf8(name.c_str()));
|
||||
localMods.insert(QString::fromUtf8(modname.c_str()).toLower(), mod);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
<Add option="-liconv" />
|
||||
<Add option="-ldbghelp" />
|
||||
<Add directory="$(#sdl2.lib)" />
|
||||
<Add directory="$(#boost.lib)" />
|
||||
<Add directory="$(#boost.lib32)" />
|
||||
<Add directory="$(#zlib.lib)" />
|
||||
</Linker>
|
||||
</Target>
|
||||
@ -110,8 +110,6 @@
|
||||
<Add option="-Wno-unused-parameter" />
|
||||
<Add option="-Wno-overloaded-virtual" />
|
||||
<Add option="-Wno-unused-local-typedefs" />
|
||||
<Add option="-Winvalid-pch" />
|
||||
<Add option="-msse2" />
|
||||
<Add option="-DVCMI_DLL" />
|
||||
<Add option="-DBOOST_THREAD_USE_LIB" />
|
||||
<Add option="-DBOOST_SYSTEM_NO_DEPRECATED" />
|
||||
@ -236,7 +234,6 @@
|
||||
<Unit filename="filesystem/Filesystem.cpp" />
|
||||
<Unit filename="filesystem/Filesystem.h" />
|
||||
<Unit filename="filesystem/ISimpleResourceLoader.h" />
|
||||
<Unit filename="filesystem/MinizipExtensions.h" />
|
||||
<Unit filename="filesystem/ResourceID.cpp" />
|
||||
<Unit filename="filesystem/ResourceID.h" />
|
||||
<Unit filename="int3.h" />
|
||||
|
@ -4,15 +4,16 @@
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
|
||||
class DLL_LINKAGE FileBuf {
|
||||
class FileBuf
|
||||
{
|
||||
public:
|
||||
typedef char char_type;
|
||||
typedef char char_type;
|
||||
typedef struct category_ :
|
||||
boost::iostreams::seekable_device_tag,
|
||||
boost::iostreams::closable_tag
|
||||
{} category;
|
||||
|
||||
FileBuf(const boost::filesystem::path& filename, std::ios_base::openmode mode = (std::ios_base::in | std::ios_base::out));
|
||||
FileBuf(const boost::filesystem::path& filename, std::ios_base::openmode mode);
|
||||
|
||||
std::streamsize read(char* s, std::streamsize n);
|
||||
std::streamsize write(const char* s, std::streamsize n);
|
||||
@ -35,7 +36,9 @@ template class DLL_LINKAGE boost::iostreams::stream<FileBuf>;
|
||||
class DLL_LINKAGE FileStream : public boost::iostreams::stream<FileBuf>
|
||||
{
|
||||
public:
|
||||
using boost::iostreams::stream<FileBuf>::stream;
|
||||
FileStream() = default;
|
||||
explicit FileStream(const boost::filesystem::path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
|
||||
: boost::iostreams::stream<FileBuf>(p, mode) {}
|
||||
|
||||
static bool CreateFile(const boost::filesystem::path& filename);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user