Apparently I didn't manage to put the class implementations in the matching
source files. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34057 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,26 +4,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ZlibDecompressor.h"
|
#include "ZlibCompressor.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
||||||
ZlibDecompressor::ZlibDecompressor()
|
ZlibCompressor::ZlibCompressor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZlibDecompressor::~ZlibDecompressor()
|
ZlibCompressor::~ZlibCompressor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ZlibDecompressor::Decompress(const void* input, size_t inputSize, void* output,
|
ZlibCompressor::Compress(const void* input, size_t inputSize, void* output,
|
||||||
size_t outputSize, size_t& _uncompressedSize)
|
size_t outputSize, size_t& _compressedSize)
|
||||||
{
|
{
|
||||||
if (inputSize == 0 || outputSize == 0)
|
if (inputSize == 0 || outputSize == 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -46,14 +46,13 @@ ZlibDecompressor::Decompress(const void* input, size_t inputSize, void* output,
|
|||||||
0 // reserved
|
0 // reserved
|
||||||
};
|
};
|
||||||
|
|
||||||
int zlibError = inflateInit(&zStream);
|
int zlibError = deflateInit(&zStream, Z_BEST_COMPRESSION);
|
||||||
if (zlibError != Z_OK)
|
if (zlibError != Z_OK)
|
||||||
return TranslateZlibError(zlibError);
|
return TranslateZlibError(zlibError);
|
||||||
|
|
||||||
|
|
||||||
// deflate
|
// deflate
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
zlibError = inflate(&zStream, Z_FINISH);
|
zlibError = deflate(&zStream, Z_FINISH);
|
||||||
if (zlibError != Z_STREAM_END) {
|
if (zlibError != Z_STREAM_END) {
|
||||||
if (zlibError == Z_OK)
|
if (zlibError == Z_OK)
|
||||||
error = B_BUFFER_OVERFLOW;
|
error = B_BUFFER_OVERFLOW;
|
||||||
@@ -62,13 +61,13 @@ ZlibDecompressor::Decompress(const void* input, size_t inputSize, void* output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
zlibError = inflateEnd(&zStream);
|
zlibError = deflateEnd(&zStream);
|
||||||
if (zlibError != Z_OK && error == B_OK)
|
if (zlibError != Z_OK && error == B_OK)
|
||||||
error = TranslateZlibError(zlibError);
|
error = TranslateZlibError(zlibError);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
_uncompressedSize = zStream.total_out;
|
_compressedSize = zStream.total_out;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,26 +4,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ZlibCompressor.h"
|
#include "ZlibDecompressor.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
||||||
ZlibCompressor::ZlibCompressor()
|
ZlibDecompressor::ZlibDecompressor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZlibCompressor::~ZlibCompressor()
|
ZlibDecompressor::~ZlibDecompressor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ZlibCompressor::Compress(const void* input, size_t inputSize, void* output,
|
ZlibDecompressor::Decompress(const void* input, size_t inputSize, void* output,
|
||||||
size_t outputSize, size_t& _compressedSize)
|
size_t outputSize, size_t& _uncompressedSize)
|
||||||
{
|
{
|
||||||
if (inputSize == 0 || outputSize == 0)
|
if (inputSize == 0 || outputSize == 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -46,13 +46,14 @@ ZlibCompressor::Compress(const void* input, size_t inputSize, void* output,
|
|||||||
0 // reserved
|
0 // reserved
|
||||||
};
|
};
|
||||||
|
|
||||||
int zlibError = deflateInit(&zStream, Z_BEST_COMPRESSION);
|
int zlibError = inflateInit(&zStream);
|
||||||
if (zlibError != Z_OK)
|
if (zlibError != Z_OK)
|
||||||
return TranslateZlibError(zlibError);
|
return TranslateZlibError(zlibError);
|
||||||
|
|
||||||
|
|
||||||
// deflate
|
// deflate
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
zlibError = deflate(&zStream, Z_FINISH);
|
zlibError = inflate(&zStream, Z_FINISH);
|
||||||
if (zlibError != Z_STREAM_END) {
|
if (zlibError != Z_STREAM_END) {
|
||||||
if (zlibError == Z_OK)
|
if (zlibError == Z_OK)
|
||||||
error = B_BUFFER_OVERFLOW;
|
error = B_BUFFER_OVERFLOW;
|
||||||
@@ -61,13 +62,13 @@ ZlibCompressor::Compress(const void* input, size_t inputSize, void* output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
zlibError = deflateEnd(&zStream);
|
zlibError = inflateEnd(&zStream);
|
||||||
if (zlibError != Z_OK && error == B_OK)
|
if (zlibError != Z_OK && error == B_OK)
|
||||||
error = TranslateZlibError(zlibError);
|
error = TranslateZlibError(zlibError);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
_compressedSize = zStream.total_out;
|
_uncompressedSize = zStream.total_out;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user