mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-28 14:17:02 -06:00
Merge continued
git-svn-id: svn://ultimatepp.org/upp/trunk@10263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
adf46bd64e
commit
2e4b276e07
3860 changed files with 1161787 additions and 438 deletions
48
uppdev/CompressedSerialize/CompressedSerialize.cpp
Normal file
48
uppdev/CompressedSerialize/CompressedSerialize.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include <Core/Core.h>
|
||||
#include <plugin/lz4/lz4.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
String h = "This is some line that is to be compressed";
|
||||
h << h;
|
||||
h << h;
|
||||
h << h;
|
||||
h << h;
|
||||
DUMP(h);
|
||||
String path = "c:/xxx/test.zc";
|
||||
|
||||
{
|
||||
FileOut fout(path);
|
||||
fout.Put("COMPRESSED");
|
||||
int64 pos = fout.GetPos();
|
||||
fout.Put64le(pos);
|
||||
Lz4 zlib;
|
||||
OutFilterStream out(fout, zlib);
|
||||
zlib.Compress();
|
||||
out % h;
|
||||
int ob = out.GetPos();
|
||||
out.Close();
|
||||
fout.Seek(pos);
|
||||
fout.Put64le(out.GetPos());
|
||||
}
|
||||
|
||||
{
|
||||
String h2;
|
||||
FileIn fin(path);
|
||||
if(fin.GetSize() < 14)
|
||||
return;
|
||||
String hdr = fin.Get(10);
|
||||
if(hdr != "COMPRESSED")
|
||||
return;
|
||||
int sz = fin.Get64le();
|
||||
DDUMP(sz);
|
||||
Lz4 zlib;
|
||||
InFilterStream in(fin, zlib);
|
||||
in.SetSize(sz);
|
||||
zlib.Decompress();
|
||||
in % h2;
|
||||
DUMP(h2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue