From 989803e96a7b2d3a3b454f3de06cbc2d33545394 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Sat, 14 Jul 2012 22:23:43 +1000 Subject: [PATCH] Support for 64-bit unpacked data size per volume --- src/fileblock.cc | 23 +++++++++++++---------- src/fileblock.h | 6 ++++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/fileblock.cc b/src/fileblock.cc index 7aa2907..5d11ef9 100644 --- a/src/fileblock.cc +++ b/src/fileblock.cc @@ -52,7 +52,8 @@ time_t date_dos2unix(unsigned short time,unsigned short date) } FileBlock::FileBlock(std::istream &in) : RARBlock(in), -in(in) +in(in), +size(RARBlock::size) { in.seekg(start + 20); unsigned short time; @@ -82,12 +83,8 @@ in(in) high_pack_size |= in.get() << 8; high_pack_size |= in.get() << 16; high_pack_size |= in.get() << 24; - if( high_pack_size ) - { - std::cerr << "Packed file size >= 4 GiB not " - "implemented" << std::endl; - std::abort(); - } + size |= static_cast (high_pack_size) << + 32; in.seekg(4, std::ios::cur); } @@ -163,6 +160,12 @@ FileBlock::~FileBlock() } +std::streamoff +FileBlock::GetEndPos() +{ + return start + headsize + size; +} + bool FileBlock::isFolder() { @@ -175,7 +178,7 @@ FileBlock::isCompressed() return compressed; } -unsigned int +unsigned long long FileBlock::GetDataSize() { return size; @@ -188,11 +191,11 @@ FileBlock::GetFileName() } int -FileBlock::GetData(char *buf, unsigned int offset, unsigned int len) +FileBlock::GetData(char *buf, std::streamoff offset, unsigned int len) { std::streampos old = in.tellg(); - in.seekg(start + headsize + offset); + in.seekg(start + std::streamoff(headsize) + offset); if ( offset > size || !len) return 0; diff --git a/src/fileblock.h b/src/fileblock.h index 8e21c3b..73c8cca 100644 --- a/src/fileblock.h +++ b/src/fileblock.h @@ -35,16 +35,18 @@ class FileBlock : public RARBlock public: FileBlock(std::istream &in); ~FileBlock(); + virtual std::streamoff GetEndPos(); std::string GetFileName(); void GetFileDate(struct timespec* tp); - unsigned int GetDataSize(); - int GetData(char *buf, unsigned int offset, unsigned int len); + unsigned long long GetDataSize(); + int GetData(char *buf, std::streamoff offset, unsigned int len); bool isFolder(); bool isCompressed(); protected: std::string filename; std::istream ∈ + unsigned long long size; bool folder; bool compressed; struct timespec filedate; -- 2.11.4.GIT