mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
BRC now support LZ4, LZMA and Zstd compression
git-svn-id: svn://ultimatepp.org/upp/trunk@11043 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1a178c9869
commit
7dd961d70c
10 changed files with 156 additions and 143 deletions
|
|
@ -4,6 +4,17 @@ BinObjInfo::BinObjInfo()
|
|||
{
|
||||
}
|
||||
|
||||
void BinObjInfo::Block::Compress(String& data)
|
||||
{
|
||||
switch(encoding) {
|
||||
case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break;
|
||||
case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break;
|
||||
case BinObjInfo::Block::ENC_LZ4: data = LZ4Compress(data); break;
|
||||
case BinObjInfo::Block::ENC_LZMA: data = LZMACompress(data); break;
|
||||
case BinObjInfo::Block::ENC_ZSTD: data = ZstdCompress(data); break;
|
||||
}
|
||||
}
|
||||
|
||||
void BinObjInfo::Parse(CParser& binscript, String base_dir)
|
||||
{
|
||||
while(!binscript.IsEof()) {
|
||||
|
|
@ -34,6 +45,12 @@ void BinObjInfo::Parse(CParser& binscript, String base_dir)
|
|||
blk.encoding = Block::ENC_ZIP;
|
||||
else if(binscript.Id("BZ2"))
|
||||
blk.encoding = Block::ENC_BZ2;
|
||||
else if(binscript.Id("LZ4"))
|
||||
blk.encoding = Block::ENC_LZ4;
|
||||
else if(binscript.Id("LZMA"))
|
||||
blk.encoding = Block::ENC_LZMA;
|
||||
else if(binscript.Id("ZSTD"))
|
||||
blk.encoding = Block::ENC_ZSTD;
|
||||
binscript.PassChar(')');
|
||||
FindFile ff;
|
||||
String searchpath = NormalizePath(file, base_dir);
|
||||
|
|
|
|||
|
|
@ -462,10 +462,7 @@ String BrcToC(CParser& binscript, String basedir)
|
|||
if(data.GetLength() != b.length)
|
||||
throw Exc(NFormat("length of file '%s' changed (%d -> %d) during object creation",
|
||||
b.file, b.length, data.GetLength()));
|
||||
switch(b.encoding) {
|
||||
case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break;
|
||||
case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break;
|
||||
}
|
||||
b.Compress(data);
|
||||
b.length = data.GetLength();
|
||||
data.Cat('\0');
|
||||
WriteByteArray(fo, data);
|
||||
|
|
@ -501,10 +498,7 @@ String BrcToC(CParser& binscript, String basedir)
|
|||
if(data.GetLength() != b.length)
|
||||
throw Exc(NFormat("length of file '%s' changed (%d -> %d) during object creation",
|
||||
b.file, b.length, data.GetLength()));
|
||||
switch(b.encoding) {
|
||||
case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break;
|
||||
case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break;
|
||||
}
|
||||
b.Compress(data);
|
||||
int b_length = data.GetLength();
|
||||
data.Cat('\0');
|
||||
WriteByteArray(fo, data);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
#define COMMON_H
|
||||
|
||||
#include <Esc/Esc.h>
|
||||
// #include <Web/Web.h>
|
||||
//#include <coff/binobj/binobj.h>
|
||||
#include <plugin/bz2/bz2.h>
|
||||
#include <plugin/lz4/lz4.h>
|
||||
#include <plugin/lzma/lzma.h>
|
||||
#include <plugin/zstd/zstd.h>
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
|
|
@ -506,6 +507,9 @@ public:
|
|||
ENC_PLAIN,
|
||||
ENC_ZIP,
|
||||
ENC_BZ2,
|
||||
ENC_LZ4,
|
||||
ENC_LZMA,
|
||||
ENC_ZSTD,
|
||||
};
|
||||
int flags;
|
||||
enum {
|
||||
|
|
@ -516,6 +520,8 @@ public:
|
|||
int offset;
|
||||
int off_meta_offset;
|
||||
int len_meta_offset;
|
||||
|
||||
void Compress(String& data);
|
||||
};
|
||||
|
||||
VectorMap< String, ArrayMap<int, Block> > blocks;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ description "TheIDE - common library\377B";
|
|||
|
||||
uses
|
||||
Esc,
|
||||
plugin/bz2;
|
||||
plugin/bz2,
|
||||
plugin/lzma;
|
||||
|
||||
file
|
||||
Core.h options(BUILDER_OPTION) PCH,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ uses
|
|||
TabBar,
|
||||
ide/Designers,
|
||||
ide/Android,
|
||||
ide/Java;
|
||||
ide/Java,
|
||||
plugin/zstd;
|
||||
|
||||
uses(POSIX) ide\SrcUpdater;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,18 @@
|
|||
|
||||
namespace Upp {
|
||||
|
||||
String BZ2Compress(String s, Gate<int, int> progress = Null);
|
||||
String BZ2Decompress(String s, Gate<int, int> progress = Null);
|
||||
String BZ2Decompress(Stream& stream, Gate<int, int> progress = Null);
|
||||
void BZ2Compress(Stream& out, Stream& in, Gate<int, int> progress = Null);
|
||||
void BZ2Decompress(Stream& out, Stream& in, Gate<int, int> progress = Null);
|
||||
|
||||
String BZ2Compress(Stream& in, Gate<int, int> progress = Null);
|
||||
String BZ2Decompress(Stream& in, Gate<int, int> progress = Null);
|
||||
|
||||
String BZ2Compress(const void *data, int64 len, Gate<int, int> progress);
|
||||
String BZ2Decompress(const void *data, int64 len, Gate<int, int> progress = Null);
|
||||
|
||||
String BZ2Compress(const String& data, Gate<int, int> progress = Null);
|
||||
String BZ2Decompress(const String& data, Gate<int, int> progress = Null);
|
||||
|
||||
}
|
||||
|
||||
#endif//__Plugin_Z__
|
||||
|
|
|
|||
|
|
@ -19,94 +19,6 @@ static void bzfree_new(void *opaque, void *addr)
|
|||
delete[] (byte *)addr;
|
||||
}
|
||||
|
||||
String BZ2Decompress(String s, Gate<int, int> progress)
|
||||
{
|
||||
if(s.IsEmpty())
|
||||
return s;
|
||||
bz_stream z;
|
||||
Zero(z);
|
||||
z.bzalloc = bzalloc_new;
|
||||
z.bzfree = bzfree_new;
|
||||
z.opaque = 0;
|
||||
if(BZ2_bzDecompressInit(&z, 0, 0) != BZ_OK)
|
||||
return String::GetVoid();
|
||||
int buf_size = minmax(s.GetLength() / 2, 1024, 65536);
|
||||
Buffer<char> output(buf_size);
|
||||
z.next_in = (char *)s.Begin();
|
||||
z.avail_in = s.GetLength();
|
||||
z.next_out = output;
|
||||
z.avail_out = buf_size;
|
||||
|
||||
String out;
|
||||
while(BZ2_bzDecompress(&z) == BZ_OK)
|
||||
{
|
||||
if(z.avail_out == (dword)buf_size)
|
||||
{ // no output generated - assume error
|
||||
BZ2_bzDecompressEnd(&z);
|
||||
return String::GetVoid();
|
||||
}
|
||||
out.Cat(output, buf_size - z.avail_out);
|
||||
z.next_out = output;
|
||||
z.avail_out = buf_size;
|
||||
if(progress((int)(uintptr_t)((const char *)z.next_in - ~s), s.GetLength()))
|
||||
{
|
||||
BZ2_bzDecompressEnd(&z);
|
||||
return String::GetVoid();
|
||||
}
|
||||
}
|
||||
if(z.avail_out < (unsigned)buf_size)
|
||||
out.Cat(output, buf_size - z.avail_out);
|
||||
|
||||
BZ2_bzDecompressEnd(&z);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
String BZ2Decompress(Stream& strm, Gate<int, int> progress)
|
||||
{
|
||||
StringStream out;
|
||||
BZ2Decompress(out, strm, progress);
|
||||
return out;
|
||||
}
|
||||
|
||||
String BZ2Compress(String s, Gate<int, int> progress)
|
||||
{
|
||||
if(s.IsEmpty())
|
||||
return s;
|
||||
bz_stream z;
|
||||
Zero(z);
|
||||
z.bzalloc = bzalloc_new;
|
||||
z.bzfree = bzfree_new;
|
||||
z.opaque = 0;
|
||||
if(BZ2_bzCompressInit(&z, 9, 0, 30) != BZ_OK)
|
||||
return String::GetVoid();
|
||||
int buf_size = minmax(s.GetLength(), 1024, 65536);
|
||||
Buffer<char> output(buf_size);
|
||||
z.next_in = (char *)s.Begin();
|
||||
z.avail_in = s.GetLength();
|
||||
z.next_out = output;
|
||||
z.avail_out = buf_size;
|
||||
|
||||
String out;
|
||||
int res;
|
||||
while((res = BZ2_bzCompress(&z, z.avail_in ? BZ_RUN : BZ_FINISH)) == BZ_RUN_OK || res == BZ_FINISH_OK)
|
||||
{
|
||||
out.Cat(output, buf_size - z.avail_out);
|
||||
z.next_out = output;
|
||||
z.avail_out = buf_size;
|
||||
if(progress((int)(uintptr_t)((const char *)z.next_in - ~s), s.GetLength()))
|
||||
{
|
||||
BZ2_bzCompressEnd(&z);
|
||||
return String::GetVoid();
|
||||
}
|
||||
}
|
||||
out.Cat(output, buf_size - z.avail_out);
|
||||
BZ2_bzCompressEnd(&z);
|
||||
if(res != BZ_STREAM_END)
|
||||
out = String::GetVoid();
|
||||
return out;
|
||||
}
|
||||
|
||||
void BZ2Decompress(Stream& out, Stream& in, Gate<int, int> progress)
|
||||
{
|
||||
enum { BUF_SIZE = 65536 };
|
||||
|
|
@ -217,4 +129,40 @@ void BZ2Compress(Stream& out, Stream& in, Gate<int, int> progress)
|
|||
out.SetError();
|
||||
}
|
||||
|
||||
String BZ2Compress(Stream& in, Gate<int, int> progress)
|
||||
{
|
||||
StringStream out;
|
||||
BZ2Compress(out, in, progress);
|
||||
return out;
|
||||
}
|
||||
|
||||
String BZ2Decompress(Stream& in, Gate<int, int> progress)
|
||||
{
|
||||
StringStream out;
|
||||
BZ2Decompress(out, in, progress);
|
||||
return out;
|
||||
}
|
||||
|
||||
String BZ2Compress(const void *data, int64 len, Gate<int, int> progress)
|
||||
{
|
||||
MemReadStream in(data, len);
|
||||
return BZ2Compress(in, progress);
|
||||
}
|
||||
|
||||
String BZ2Decompress(const void *data, int64 len, Gate<int, int> progress)
|
||||
{
|
||||
MemReadStream in(data, len);
|
||||
return BZ2Decompress(in, progress);
|
||||
}
|
||||
|
||||
String BZ2Compress(const String& data, Gate<int, int> progress)
|
||||
{
|
||||
return BZ2Compress(~data, data.GetLength(), progress);
|
||||
}
|
||||
|
||||
String BZ2Decompress(const String& data, Gate<int, int> progress)
|
||||
{
|
||||
return BZ2Decompress(~data, data.GetLength(), progress);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ public:
|
|||
|
||||
int64 LZ4Compress(Stream& out, Stream& in, Gate<int64, int64> progress = Null);
|
||||
int64 LZ4Decompress(Stream& out, Stream& in, Gate<int64, int64> progress = Null);
|
||||
String LZ4Compress(Stream& in, Gate<int64, int64> progress = Null);
|
||||
String LZ4Decompress(Stream& in, Gate<int64, int64> progress = Null);
|
||||
String LZ4Compress(const void *data, int64 len, Gate<int64, int64> progress = Null);
|
||||
String LZ4Compress(const String& s, Gate<int64, int64> progress = Null);
|
||||
String LZ4Decompress(const void *data, int64 len, Gate<int64, int64> progress = Null);
|
||||
|
|
@ -121,6 +123,8 @@ String LZ4Decompress(const String& s, Gate<int64, int64> progress = Null);
|
|||
#ifdef _MULTITHREADED
|
||||
int64 CoLZ4Compress(Stream& out, Stream& in, Gate<int64, int64> progress = Null);
|
||||
int64 CoLZ4Decompress(Stream& out, Stream& in, Gate<int64, int64> progress = Null);
|
||||
String CoLZ4Compress(Stream& in, Gate<int64, int64> progress = Null);
|
||||
String CoLZ4Decompress(Stream& in, Gate<int64, int64> progress = Null);
|
||||
String CoLZ4Compress(const void *data, int64 len, Gate<int64, int64> progress = Null);
|
||||
String CoLZ4Compress(const String& s, Gate<int64, int64> progress = Null);
|
||||
String CoLZ4Decompress(const void *data, int64 len, Gate<int64, int64> progress = Null);
|
||||
|
|
|
|||
|
|
@ -59,54 +59,66 @@ ressStream]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in])&]
|
|||
[s0;*@7;4%% &]
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 LZ4 Compress/Decompress functions]]}}&]
|
||||
[s3; &]
|
||||
[s5;:Upp`:`:LZ4Compress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
[s5;:Upp`:`:LZ4Compress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
nt64]_[* LZ4Compress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 out],
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
nt64]_[* LZ4Decompress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 out],
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:LZ4Compress`(const void`*`,Upp`:`:int64`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:LZ4Compress`(Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* LZ4Compress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in],
|
||||
[_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress])&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* LZ4Decompress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in],
|
||||
[_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress])&]
|
||||
[s5;:Upp`:`:LZ4Compress`(const void`*`,Upp`:`:int64`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* LZ4Compress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data],
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64
|
||||
], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:LZ4Compress`(const Upp`:`:String`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64],
|
||||
[_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:LZ4Compress`(const Upp`:`:String`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* LZ4Compress]([@(0.0.255) const]_[_^Upp`:`:String^ String][@(0.0.255) `&]_[*@3 s],
|
||||
[_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 p
|
||||
rogress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(const void`*`,Upp`:`:int64`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=
|
||||
_Null)&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(const void`*`,Upp`:`:int64`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* LZ4Decompress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data],
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64
|
||||
], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(const Upp`:`:String`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64],
|
||||
[_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:LZ4Decompress`(const Upp`:`:String`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* LZ4Decompress]([@(0.0.255) const]_[_^Upp`:`:String^ String][@(0.0.255) `&]_[*@3 s
|
||||
], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 p
|
||||
rogress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_
|
||||
`=_Null)&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
nt64]_[* CoLZ4Compress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 out],
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(Upp`:`:Stream`&`,Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:int64^ i
|
||||
nt64]_[* CoLZ4Decompress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 out],
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(const void`*`,Upp`:`:int64`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ i
|
||||
nt64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* CoLZ4Compress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in],
|
||||
[_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress])&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(Upp`:`:Stream`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* CoLZ4Decompress]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 in],
|
||||
[_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress])&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(const void`*`,Upp`:`:int64`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* CoLZ4Compress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data],
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64
|
||||
], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(const Upp`:`:String`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64],
|
||||
[_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:CoLZ4Compress`(const Upp`:`:String`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* CoLZ4Compress]([@(0.0.255) const]_[_^Upp`:`:String^ String][@(0.0.255) `&]_[*@3 s
|
||||
], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 p
|
||||
rogress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(const void`*`,Upp`:`:int64`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_
|
||||
`=_Null)&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(const void`*`,Upp`:`:int64`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* CoLZ4Decompress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data],
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64
|
||||
], [_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(const Upp`:`:String`&`,Upp`:`:EventGate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
[_^Upp`:`:int64^ int64]_[*@3 len], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64],
|
||||
[_^Upp`:`:int64^ int64]>_[*@3 progress]_`=_Null)&]
|
||||
[s5;:Upp`:`:CoLZ4Decompress`(const Upp`:`:String`&`,Upp`:`:Gate`<Upp`:`:int64`,Upp`:`:int64`>`): [_^Upp`:`:String^ S
|
||||
tring]_[* CoLZ4Decompress]([@(0.0.255) const]_[_^Upp`:`:String^ String][@(0.0.255) `&]_[*@3 s
|
||||
], [_^Upp`:`:EventGate^ EventGate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 p
|
||||
rogress]_`=_[@(0.0.255) false])&]
|
||||
], [_^Upp`:`:Gate^ Gate]<[_^Upp`:`:int64^ int64], [_^Upp`:`:int64^ int64]>_[*@3 progress]_
|
||||
`=_Null)&]
|
||||
[s2;%% Simple LZ4 compression/decompression functions. [%-*@3 out]
|
||||
[%-*@3 in] parameters are input / ouput streams and function returns
|
||||
the number of bytes stored to [%-*@3 out], otherwise input is provided
|
||||
|
|
@ -115,6 +127,7 @@ as memory block [%-*@3 data] of [%-*@3 len] bytes or as input String
|
|||
can be used to to track progress of operation and eventually
|
||||
interrupt it by returning true. Functions with Co prefix run
|
||||
multithreaded.&]
|
||||
[s2;%% &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:IsLZ4`(Upp`:`:Stream`&`): [@(0.0.255) bool]_[* IsLZ4]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&
|
||||
|
|
@ -123,4 +136,5 @@ multithreaded.&]
|
|||
Seeks back after the check. Returns true if magic number was
|
||||
detected.&]
|
||||
[s3;%% &]
|
||||
[s3;%% &]
|
||||
[s0;%% ]]
|
||||
|
|
@ -42,13 +42,24 @@ int64 LZ4Decompress(Stream& out, Stream& in, Gate<int64, int64> progress)
|
|||
return sLZ4Decompress(out, in, in.GetLeft(), progress, false);
|
||||
}
|
||||
|
||||
String LZ4Compress(const void *data, int64 len, Gate<int64, int64> progress)
|
||||
String LZ4Compress(Stream& in, Gate<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
MemReadStream in(data, len);
|
||||
return LZ4Compress(out, in, progress) < 0 ? String::GetVoid() : out.GetResult();
|
||||
}
|
||||
|
||||
String LZ4Decompress(Stream& in, Gate<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
return LZ4Decompress(out, in, progress) < 0 ? String::GetVoid() : out.GetResult();
|
||||
}
|
||||
|
||||
String LZ4Compress(const void *data, int64 len, Gate<int64, int64> progress)
|
||||
{
|
||||
MemReadStream in(data, len);
|
||||
return LZ4Compress(in, progress);
|
||||
}
|
||||
|
||||
String LZ4Compress(const String& s, Gate<int64, int64> progress)
|
||||
{
|
||||
return LZ4Compress(~s, s.GetLength(), progress);
|
||||
|
|
@ -56,9 +67,8 @@ String LZ4Compress(const String& s, Gate<int64, int64> progress)
|
|||
|
||||
String LZ4Decompress(const void *data, int64 len, Gate<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
MemReadStream in(data, len);
|
||||
return LZ4Decompress(out, in, progress) < 0 ? String::GetVoid() : out.GetResult();
|
||||
return LZ4Decompress(in, progress);
|
||||
}
|
||||
|
||||
String LZ4Decompress(const String& s, Gate<int64, int64> progress)
|
||||
|
|
@ -78,6 +88,18 @@ int64 CoLZ4Decompress(Stream& out, Stream& in, Gate<int64, int64> progress)
|
|||
return sLZ4Decompress(out, in, in.GetLeft(), progress, true);
|
||||
}
|
||||
|
||||
String CoLZ4Compress(Stream& in, Gate<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
return CoLZ4Compress(out, in, progress) < 0 ? String::GetVoid() : out.GetResult();
|
||||
}
|
||||
|
||||
String CoLZ4Decompress(Stream& in, Gate<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
return CoLZ4Decompress(out, in, progress) < 0 ? String::GetVoid() : out.GetResult();
|
||||
}
|
||||
|
||||
String CoLZ4Compress(const void *data, int64 len, Gate<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue