AuroraRuntime/Source/Compression/BlockCompressor.cpp

61 lines
1.4 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: BlockCompressor.cpp
Date: 2021-6-17
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include "Compression.hpp"
#include "BlockCompressor.hpp"
#include "bzlib.h"
#include "zstd.h"
#include "zlib.h"
#include "lz4.h"
namespace Aurora::Compression
{
std::pair<AuUInt32, AuUInt32> BaseStreamDeflate::Ingest(AuUInt32 input)
{
auto ingest = IngestImpl(input);
_count += ingest.first;
return ingest;
}
2021-06-27 21:25:29 +00:00
bool BaseStreamDeflate::Read(void * /*opt*/ buffer, AuUInt32 &len, bool ingestUntilError)
{
if (_count != _lastCount)
{
Flush();
}
2021-06-27 21:25:29 +00:00
if (ingestUntilError)
{
while (this->_outbuffer.size() < len)
{
if (Ingest(4096).second == 0)
2021-06-27 21:25:29 +00:00
{
if (this->_outbuffer.size())
{
break;
}
2021-06-27 21:25:29 +00:00
return false;
}
}
}
return !buffer || StreamRead(buffer, len, this->_outbuffer);
2021-06-27 21:25:29 +00:00
}
AUKN_SYM ICompressionStream *CompressorNew(IO::IStreamReader *reader, const CompressionInfo &info)
2021-06-27 21:25:29 +00:00
{
return nullptr;
}
AUKN_SYM void CompressorRelease(ICompressionStream * stream)
2021-06-27 21:25:29 +00:00
{
SafeDelete<BaseStreamDeflate *>(stream);
}
}