Skip to content

Commit

Permalink
Support for 64-bit unpacked data size per volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Panter committed Jul 15, 2012
1 parent 2e22d34 commit 989803e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
23 changes: 13 additions & 10 deletions src/fileblock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <unsigned long long>(high_pack_size) <<
32;
in.seekg(4, std::ios::cur);
}

Expand Down Expand Up @@ -163,6 +160,12 @@ FileBlock::~FileBlock()

}

std::streamoff
FileBlock::GetEndPos()
{
return start + headsize + size;
}

bool
FileBlock::isFolder()
{
Expand All @@ -175,7 +178,7 @@ FileBlock::isCompressed()
return compressed;
}

unsigned int
unsigned long long
FileBlock::GetDataSize()
{
return size;
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/fileblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 &in;
unsigned long long size;
bool folder;
bool compressed;
struct timespec filedate;
Expand Down

0 comments on commit 989803e

Please sign in to comment.