diff --git a/Athena.pri b/Athena.pri index e9847d6..5e1b856 100644 --- a/Athena.pri +++ b/Athena.pri @@ -45,6 +45,7 @@ SOURCES += \ $$PWD/src/sha1.cpp \ $$PWD/src/aes.c \ $$PWD/src/lzo.c +win32:SOURCES += $$PWD/src/win32_largefilewrapper.c HEADERS += \ $$PWD/include/Athena/Stream.hpp \ @@ -102,6 +103,9 @@ HEADERS += \ $$PWD/include/Athena/ZQuestFileReader.hpp \ $$PWD/include/Athena/ZQuestFileWriter.hpp +win32:HEADERS += \ + $$PWD/Athena/include/win32_largefilewrapper.h + OTHER_FILES += \ .travis.yml diff --git a/include/Athena/Global.hpp b/include/Athena/Global.hpp index ae6ae82..5b26583 100644 --- a/include/Athena/Global.hpp +++ b/include/Athena/Global.hpp @@ -20,6 +20,10 @@ #include "Athena/Utility.hpp" #include +#if !defined(__PRETTY_FUNCTION__) && defined(_WIN32) +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + #ifndef aDebug #define aDebug() \ std::cout << __FILE__ << "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << ": " @@ -59,7 +63,7 @@ namespace Sakura template class Vector2D -{ +{ifndef public: T x; T y; diff --git a/include/win32_largefilewrapper.h b/include/win32_largefilewrapper.h new file mode 100644 index 0000000..0211813 --- /dev/null +++ b/include/win32_largefilewrapper.h @@ -0,0 +1,16 @@ +#ifndef WIN32_LARGEFILEWRAPPER_H +#define WIN32_LARGEFILEWRAPPER_H + +#ifdef _WIN32 +#include +#ifdef __cplusplus +extern "C" { +#endif +int fseeko64(FILE* fp, off64_t offset, int whence); +int ftello64(FILE* fp); +#ifdef __cplusplus +} +#endif +#endif + +#endif // WIN32_LARGEFILEWRAPPER_H diff --git a/src/Athena/BinaryWriter.cpp b/src/Athena/BinaryWriter.cpp index b2e64f3..65a5ef7 100644 --- a/src/Athena/BinaryWriter.cpp +++ b/src/Athena/BinaryWriter.cpp @@ -54,11 +54,7 @@ BinaryWriter::BinaryWriter(const std::string& filename, std::function m_length = 0x10; m_bitPosition = 0; m_position = 0; -#ifdef HW_RVL - m_data = (Uint8*)memalign(32, m_length); -#else m_data = new Uint8[m_length]; -#endif if (!m_data) THROW_IO_EXCEPTION("Could not allocate memory!"); @@ -159,11 +155,7 @@ std::string BinaryWriter::filepath() const void BinaryWriter::setData(const Uint8* data, Uint64 length) { if (m_data) -#ifdef HW_RVL - free(m_data); -#else delete[] m_data; -#endif m_data = (Uint8*)data; m_length = length; diff --git a/src/Athena/FileReader.cpp b/src/Athena/FileReader.cpp index 09b35d3..a520c44 100644 --- a/src/Athena/FileReader.cpp +++ b/src/Athena/FileReader.cpp @@ -20,6 +20,10 @@ #include "Athena/IOException.hpp" #include "utf8.h" +#ifdef _WIN32 +#include "win32_largefilewrapper.h" +#endif + namespace Athena { namespace io diff --git a/src/win32_largefilewrapper.c b/src/win32_largefilewrapper.c new file mode 100644 index 0000000..6d13829 --- /dev/null +++ b/src/win32_largefilewrapper.c @@ -0,0 +1,14 @@ +#include "win32_largefilewrapper.h" +#include + +#ifdef _WIN32 +int fseeko64(FILE* fp, off64_t offset, int whence) +{ + return _fseeki64(fp, offset, whence); +} + +int ftello64(FILE* fp) +{ + return _ftelli64(fp); +} +#endif