From fd84808762fcae588d50d9522e50a43c90da41d2 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 26 Jan 2017 19:25:48 -0800 Subject: [PATCH] Windows build fix #2 --- CMakeLists.txt | 3 +- src/athena/FileWriterGeneric.cpp | 35 +++++++++++++++++++ .../{FileWriter.cpp => FileWriterNix.cpp} | 29 --------------- 3 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/athena/FileWriterGeneric.cpp rename src/athena/{FileWriter.cpp => FileWriterNix.cpp} (79%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b81ef2..1787b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ if(WIN32) list(APPEND CORE_EXTRA src/win32_largefilewrapper.c include/win32_largefilewrapper.h src/athena/FileWriterWin32.cpp src/athena/FileReaderWin32.cpp) else() -list(APPEND CORE_EXTRA src/athena/FileWriter.cpp src/athena/FileReader.cpp) +list(APPEND CORE_EXTRA src/athena/FileWriterNix.cpp src/athena/FileReader.cpp) if(APPLE OR GEKKO OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") list(APPEND CORE_EXTRA src/osx_largefilewrapper.c include/osx_largefilewrapper.h) if(GEKKO) @@ -42,6 +42,7 @@ add_library(athena-core src/athena/Utility.cpp src/athena/MemoryReader.cpp src/athena/MemoryWriter.cpp + src/athena/FileWriterGeneric.cpp src/athena/Global.cpp src/athena/Checksums.cpp src/athena/Compression.cpp diff --git a/src/athena/FileWriterGeneric.cpp b/src/athena/FileWriterGeneric.cpp new file mode 100644 index 0000000..b771c6c --- /dev/null +++ b/src/athena/FileWriterGeneric.cpp @@ -0,0 +1,35 @@ +#include "athena/FileWriter.hpp" + +namespace athena +{ +namespace io +{ +void TransactionalFileWriter::seek(atInt64 pos, SeekOrigin origin) +{ + switch (origin) + { + case SeekOrigin::Begin: + m_position = pos; + break; + case SeekOrigin::Current: + m_position += pos; + break; + case SeekOrigin::End: + break; + } +} + +void TransactionalFileWriter::writeUBytes(const atUint8* data, atUint64 len) +{ + atUint64 neededSz = m_position + len; + if (neededSz > m_deferredBuffer.size()) + { + m_deferredBuffer.reserve(neededSz * 2); + m_deferredBuffer.resize(neededSz); + } + + memmove(m_deferredBuffer.data() + m_position, data, len); + m_position += len; +} +} +} diff --git a/src/athena/FileWriter.cpp b/src/athena/FileWriterNix.cpp similarity index 79% rename from src/athena/FileWriter.cpp rename to src/athena/FileWriterNix.cpp index 075b38f..8844669 100644 --- a/src/athena/FileWriter.cpp +++ b/src/athena/FileWriterNix.cpp @@ -128,34 +128,5 @@ void FileWriter::writeUBytes(const atUint8* data, atUint64 len) setError(); } } - -void TransactionalFileWriter::seek(atInt64 pos, SeekOrigin origin) -{ - switch (origin) - { - case SeekOrigin::Begin: - m_position = pos; - break; - case SeekOrigin::Current: - m_position += pos; - break; - case SeekOrigin::End: - break; - } -} - -void TransactionalFileWriter::writeUBytes(const atUint8* data, atUint64 len) -{ - atUint64 neededSz = m_position + len; - if (neededSz > m_deferredBuffer.size()) - { - m_deferredBuffer.reserve(neededSz * 2); - m_deferredBuffer.resize(neededSz); - } - - memmove(m_deferredBuffer.data() + m_position, data, len); - m_position += len; -} - } } // Athena