1/*
2Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
3Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
4
5This library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Lesser General Public
7License version 2.1 as published by the Free Software Foundation.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public
15License along with this library; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "7z.h"
20
21#include "lzmadec.h"
22
23bool decompress_lzma_7z(ISequentialInStream& in, unsigned in_size, ISequentialOutStream& out, unsigned out_size) throw ()
24{
25 try
26 {
27 NCompress::NLZMA::CDecoder cc;
28
29 UINT64 in_size_l = in_size;
30 UINT64 out_size_l = out_size;
31
32 if (cc.ReadCoderProperties(&in) != S_OK) { return(false); }
33 if (cc.Code(&in, &out, &in_size_l, &out_size_l) != S_OK) { return(false); }
34 if (out.size_get() != out_size || out.overflow_get()) { return(false); }
35
36 return(true);
37 }
38 catch (...)
39 {
40 return(false);
41 }
42}
43
44bool decompress_lzma_7z(const unsigned char* in_data, unsigned int in_size, unsigned char* out_data, unsigned int out_size) throw ()
45{
46 ISequentialInStream_Array in(reinterpret_cast<const char*>(in_data), in_size);
47 ISequentialOutStream_Array out(reinterpret_cast<char*>(out_data), out_size);
48
49 return(decompress_lzma_7z(in, in_size, out, out_size));
50}
51