mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Fixed TAR parser
This commit is contained in:
parent
19eb3fba7f
commit
0c7601c831
15
src/tar.cpp
15
src/tar.cpp
@ -45,18 +45,23 @@ static quint64 number(const char* data, size_t size)
|
|||||||
|
|
||||||
bool Tar::load(const QString &path)
|
bool Tar::load(const QString &path)
|
||||||
{
|
{
|
||||||
struct Header hdr;
|
char buffer[BLOCKSIZE];
|
||||||
|
struct Header *hdr = (struct Header*)&buffer;
|
||||||
quint64 size;
|
quint64 size;
|
||||||
|
qint64 ret;
|
||||||
|
|
||||||
_file.setFileName(path);
|
_file.setFileName(path);
|
||||||
if (!_file.open(QIODevice::ReadOnly))
|
if (!_file.open(QIODevice::ReadOnly))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (_file.read((char*)&hdr, BLOCKSIZE)) {
|
while ((ret = _file.read(buffer, BLOCKSIZE)) > 0) {
|
||||||
size = number(hdr.size, sizeof(hdr.size));
|
if (ret < BLOCKSIZE)
|
||||||
|
return false;
|
||||||
|
size = number(hdr->size, sizeof(hdr->size));
|
||||||
if (size)
|
if (size)
|
||||||
_index.insert(hdr.name, Info(size, _file.pos()));
|
_index.insert(hdr->name, Info(size, _file.pos()));
|
||||||
_file.seek(_file.pos() + BLOCKCOUNT(size) * BLOCKSIZE);
|
if (!_file.seek(_file.pos() + BLOCKCOUNT(size) * BLOCKSIZE))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user