diff --git a/Jupiter/DataBuffer.cpp b/Jupiter/DataBuffer.cpp index 568d877..ee90371 100644 --- a/Jupiter/DataBuffer.cpp +++ b/Jupiter/DataBuffer.cpp @@ -26,6 +26,46 @@ Jupiter::DataBuffer::DataBuffer(size_t size_) Jupiter::DataBuffer::bufferSize = size_; } +Jupiter::DataBuffer::DataBuffer(FILE *file) +{ + fread(std::addressof(Jupiter::DataBuffer::bufferSize), sizeof(size_t), 1, file); + Jupiter::DataBuffer::base = reinterpret_cast(malloc(Jupiter::DataBuffer::bufferSize * sizeof(uint8_t))); + Jupiter::DataBuffer::head = Jupiter::DataBuffer::base; + Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + Jupiter::DataBuffer::bufferSize; + int chr; + while (Jupiter::DataBuffer::head != Jupiter::DataBuffer::end) + { + chr = fgetc(file); + if (chr == EOF) + { + Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + 1; + break; + } + *Jupiter::DataBuffer::head++ = static_cast(chr); + } + Jupiter::DataBuffer::head = Jupiter::DataBuffer::base; +} + +Jupiter::DataBuffer::DataBuffer(FILE *file, size_t size_) +{ + Jupiter::DataBuffer::bufferSize = size_; + Jupiter::DataBuffer::base = reinterpret_cast(malloc(Jupiter::DataBuffer::bufferSize * sizeof(uint8_t))); + Jupiter::DataBuffer::head = Jupiter::DataBuffer::base; + Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + Jupiter::DataBuffer::bufferSize; + int chr; + while (Jupiter::DataBuffer::head != Jupiter::DataBuffer::end) + { + chr = fgetc(file); + if (chr == EOF) + { + Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + 1; + break; + } + *Jupiter::DataBuffer::head++ = static_cast(chr); + } + Jupiter::DataBuffer::head = Jupiter::DataBuffer::base; +} + Jupiter::DataBuffer::~DataBuffer() { free(Jupiter::DataBuffer::base); diff --git a/Jupiter/DataBuffer.h b/Jupiter/DataBuffer.h index 7aa3df3..d7ddfab 100644 --- a/Jupiter/DataBuffer.h +++ b/Jupiter/DataBuffer.h @@ -24,6 +24,7 @@ */ #include +#include #include "Jupiter.h" namespace Jupiter @@ -201,6 +202,8 @@ namespace Jupiter DataBuffer(); DataBuffer(size_t size); + DataBuffer(FILE *file); + DataBuffer(FILE *file, size_t size); ~DataBuffer(); private: diff --git a/Jupiter/Jupiter.vcxproj b/Jupiter/Jupiter.vcxproj index b734a82..47ccdc0 100644 --- a/Jupiter/Jupiter.vcxproj +++ b/Jupiter/Jupiter.vcxproj @@ -179,6 +179,7 @@ + diff --git a/Jupiter/Jupiter.vcxproj.filters b/Jupiter/Jupiter.vcxproj.filters index 436b71b..0c4fa0f 100644 --- a/Jupiter/Jupiter.vcxproj.filters +++ b/Jupiter/Jupiter.vcxproj.filters @@ -126,6 +126,9 @@ Source Files + + Source Files\Files + diff --git a/Jupiter/SLList.h b/Jupiter/SLList.h index 3040520..85e1f04 100644 --- a/Jupiter/SLList.h +++ b/Jupiter/SLList.h @@ -161,12 +161,7 @@ template typename Jupiter::SLList::Node *Jupiter::SLList::getN return t; } -template T *Jupiter::SLList::get(size_t index) -{ - return Jupiter::SLList::getNode(index)->data; -} - -template const T *Jupiter::SLList::get(size_t index) const +template T *Jupiter::SLList::get(size_t index) const { return Jupiter::SLList::getNode(index)->data; } diff --git a/Release/Jupiter.lib b/Release/Jupiter.lib index 5d13d17..086f99e 100644 Binary files a/Release/Jupiter.lib and b/Release/Jupiter.lib differ