mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
[unpaker2] lzma decoder.
This commit is contained in:
parent
6b1db00fe6
commit
b3c0b0489e
2 changed files with 25 additions and 3 deletions
|
|
@ -32,6 +32,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include <lzma.h>
|
||||
#include <lzo/lzo1x.h>
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -135,12 +136,30 @@ void unpack_file(path fn) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case segment::decode_algorithm::lzma:
|
||||
case segment::decode_algorithm::lzma: {
|
||||
uint8_t flags = s;
|
||||
|
||||
lzma_stream strm{};
|
||||
strm.next_in = s.p;
|
||||
strm.avail_in = len;
|
||||
strm.next_out = pp;
|
||||
strm.avail_out = 1'000'000;
|
||||
|
||||
auto r = lzma_auto_decoder(&strm, 1'000'000'000, flags);
|
||||
if (r != LZMA_OK) {
|
||||
throw std::runtime_error{"lzma error"};
|
||||
}
|
||||
r = lzma_code(&strm, LZMA_RUN);
|
||||
if (r != LZMA_STREAM_END) {
|
||||
throw std::runtime_error{"lzma error"};
|
||||
}
|
||||
pp += strm.total_out;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error{"compression unsupported: "s + std::to_string(seg.algorithm)};
|
||||
}
|
||||
}
|
||||
exi:
|
||||
pp = bbb.data();
|
||||
|
||||
auto dir = fn += ".dir2";
|
||||
|
|
|
|||
5
sw.cpp
5
sw.cpp
|
|
@ -54,7 +54,10 @@ void build(Solution &s)
|
|||
auto &unpaker = add_exe_base("unpaker"); // 32-bit only
|
||||
if (unpaker.getBuildSettings().TargetOS.Arch != ArchType::x86)
|
||||
unpaker.HeaderOnly = true;
|
||||
add_exe_with_common("unpaker2") += "org.sw.demo.oberhumer.lzo.lzo"_dep;
|
||||
add_exe_with_common("unpaker2") +=
|
||||
"org.sw.demo.oberhumer.lzo.lzo"_dep,
|
||||
"org.sw.demo.xz_utils.lzma"_dep
|
||||
;
|
||||
|
||||
// not so simple targets
|
||||
auto &script2txt = add_exe_with_common("script2txt");
|
||||
|
|
|
|||
Loading…
Reference in a new issue