diff --git a/Common/cppcf/compoundfile.cpp b/Common/cppcf/compoundfile.cpp index 3e9e33d953..5361c86f41 100644 --- a/Common/cppcf/compoundfile.cpp +++ b/Common/cppcf/compoundfile.cpp @@ -208,6 +208,7 @@ void CompoundFile::Load(Stream stream) sectors.Clear(); + auto pos = stream->tellg(); //sectors = new ArrayList(); for (int i = 0; i < n_sector; i++) { diff --git a/Common/cppcf/directoryentry.cpp b/Common/cppcf/directoryentry.cpp index 1782832fff..85f8c79d04 100644 --- a/Common/cppcf/directoryentry.cpp +++ b/Common/cppcf/directoryentry.cpp @@ -270,7 +270,7 @@ ULONG64 DirectoryEntry::fnv_hash(const char *buffer, int lenght) std::shared_ptr DirectoryEntry::New(std::wstring name, StgType stgType, SVector dirRepository) { std::shared_ptr de; - if (dirRepository.size()) + if (/*dirRepository != null*/true) { de.reset(new DirectoryEntry(name, stgType, dirRepository)); // No invalid directory entry found diff --git a/Common/cppcf/sector.cpp b/Common/cppcf/sector.cpp index bc1a8c60c2..e91aa2b0ea 100644 --- a/Common/cppcf/sector.cpp +++ b/Common/cppcf/sector.cpp @@ -22,17 +22,8 @@ bool Sector::IsStreamed() if (stream == nullptr || size == MINISECTOR_SIZE) return false; - auto currentPossition = stream->tellg(); - - stream->seekg(std::ios_base::end); - auto endPossition = stream->tellg(); - stream->seekg(std::ios_base::beg); - auto begPossition = stream->tellg(); - auto streamSize = endPossition - begPossition; - - stream->seekg(currentPossition, std::ios_base::beg); - - return (this->id * size) + size < streamSize; + auto fileSize = Length(stream); + return (this->id * size) + size < fileSize; } void Sector::ZeroData() diff --git a/Common/cppcf/streamview.cpp b/Common/cppcf/streamview.cpp index 66b336acd8..248c256828 100644 --- a/Common/cppcf/streamview.cpp +++ b/Common/cppcf/streamview.cpp @@ -10,6 +10,7 @@ StreamView::StreamView(const SVector §orChain, int sectorSize, Strea // if (sectorChain == null) // throw CFException("Sector Chain cannot be null"); + auto pos = stream->tellg(); if (sectorSize <= 0) throw CFException("Sector size must be greater than zero"); } @@ -172,7 +173,7 @@ void StreamView::SetLength(std::streamsize value) int StreamView::ReadInt32() { Read(reinterpret_cast(&buf), 0, 4); - return ((buf & 0xFF) << 24) | ((buf & 0x00FF) << 16) | ((buf & 0x0000FF) << 8) | (buf & 0x000000FF); + return buf; } void StreamView::WriteInt32(int val) diff --git a/Common/cppcf/streamview.h b/Common/cppcf/streamview.h index 92d40ae32a..6ff1dbdc04 100644 --- a/Common/cppcf/streamview.h +++ b/Common/cppcf/streamview.h @@ -39,6 +39,6 @@ private: public: Stream stream; SList freeSectors; - std::streamsize position; + std::streamsize position = 0; }; }