summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/GZipFile.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-19 20:13:05 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-19 20:13:05 +0100
commit1635c696de75e17adaeee65531fa9b864542cca8 (patch)
treefbea00253179bfb2e11d5a8899071cbc191091ab /src/OSSupport/GZipFile.cpp
parentAdded unreachable lines backit prtected by preprocessor guards (diff)
parentAPIDump: Reformatted the plugin to avoid all ZBS Analyzer issues. (diff)
downloadcuberite-1635c696de75e17adaeee65531fa9b864542cca8.tar
cuberite-1635c696de75e17adaeee65531fa9b864542cca8.tar.gz
cuberite-1635c696de75e17adaeee65531fa9b864542cca8.tar.bz2
cuberite-1635c696de75e17adaeee65531fa9b864542cca8.tar.lz
cuberite-1635c696de75e17adaeee65531fa9b864542cca8.tar.xz
cuberite-1635c696de75e17adaeee65531fa9b864542cca8.tar.zst
cuberite-1635c696de75e17adaeee65531fa9b864542cca8.zip
Diffstat (limited to 'src/OSSupport/GZipFile.cpp')
-rw-r--r--src/OSSupport/GZipFile.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/OSSupport/GZipFile.cpp b/src/OSSupport/GZipFile.cpp
index cbf6be6c4..b13e519e0 100644
--- a/src/OSSupport/GZipFile.cpp
+++ b/src/OSSupport/GZipFile.cpp
@@ -73,12 +73,15 @@ int cGZipFile::ReadRestOfFile(AString & a_Contents)
// Since the gzip format doesn't really support getting the uncompressed length, we need to read incrementally. Yuck!
int NumBytesRead = 0;
+ int TotalBytes = 0;
char Buffer[64 KiB];
while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
{
+ TotalBytes += NumBytesRead;
a_Contents.append(Buffer, NumBytesRead);
}
- return NumBytesRead;
+ // NumBytesRead is < 0 on error
+ return (NumBytesRead >= 0) ? TotalBytes : NumBytesRead;
}