From 180ead8188e312d0014ea03eb5e91a9d9e0adf3c Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 18 Jul 2022 09:49:27 -0700 Subject: [PATCH] lib: fix win32 issues --- lib/interleaf.cpp | 8 ++++---- lib/object.cpp | 20 ++++++++++++++++++++ lib/sitypes.h | 2 +- lib/types.h | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/interleaf.cpp b/lib/interleaf.cpp index 77cac1f..e8c6834 100644 --- a/lib/interleaf.cpp +++ b/lib/interleaf.cpp @@ -49,18 +49,18 @@ Interleaf::Error Interleaf::Write(const char *f) const #ifdef _WIN32 Interleaf::Error Interleaf::Read(const wchar_t *f) { - std::istream is(f); + std::ifstream is(f); if (!is.is_open() || !is.good()) { - return false; + return ERROR_IO; } return Read(is); } Interleaf::Error Interleaf::Write(const wchar_t *f) const { - std::ostream os(f); + std::ofstream os(f); if (!os.is_open() || !os.good()) { - return false; + return ERROR_IO; } return Write(os); } diff --git a/lib/object.cpp b/lib/object.cpp index 288a197..0c705ce 100644 --- a/lib/object.cpp +++ b/lib/object.cpp @@ -13,6 +13,26 @@ Object::Object() id_ = 0; } +#ifdef _WIN32 +bool Object::ReplaceWithFile(const wchar_t *f) +{ + std::ifstream is(f); + if (!is.is_open() || !is.good()) { + return false; + } + return ReplaceWithFile(is); +} + +bool Object::ExtractToFile(const wchar_t *f) const +{ + std::ofstream os(f); + if (!os.is_open() || !os.good()) { + return false; + } + return ExtractToFile(os); +} +#endif + bool Object::ReplaceWithFile(const char *f) { std::ifstream is(f); diff --git a/lib/sitypes.h b/lib/sitypes.h index 8a763d9..9acc999 100644 --- a/lib/sitypes.h +++ b/lib/sitypes.h @@ -47,7 +47,7 @@ public: return std::string((const char *) &u, sizeof(u)); } - static const char *GetTypeDescription(Type t); + LIBWEAVER_EXPORT static const char *GetTypeDescription(Type t); }; diff --git a/lib/types.h b/lib/types.h index 7e59bd4..0fb1561 100644 --- a/lib/types.h +++ b/lib/types.h @@ -120,7 +120,7 @@ public: }; -LIBWEAVER_EXPORT class memorybuf : public std::streambuf +class memorybuf : public std::streambuf { public: memorybuf(){}