Path: blob/main/misc/emulator/xnes/snes9x/jma/7zlzma.cpp
28798 views
/*1Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )2Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )34This library is free software; you can redistribute it and/or5modify it under the terms of the GNU Lesser General Public6License version 2.1 as published by the Free Software Foundation.78This library is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11Lesser General Public License for more details.1213You should have received a copy of the GNU Lesser General Public14License along with this library; if not, write to the Free Software15Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16*/1718#include "7z.h"1920#include "lzmadec.h"2122bool decompress_lzma_7z(ISequentialInStream& in, unsigned in_size, ISequentialOutStream& out, unsigned out_size) throw ()23{24try25{26NCompress::NLZMA::CDecoder cc;2728UINT64 in_size_l = in_size;29UINT64 out_size_l = out_size;3031if (cc.ReadCoderProperties(&in) != S_OK) { return(false); }32if (cc.Code(&in, &out, &in_size_l, &out_size_l) != S_OK) { return(false); }33if (out.size_get() != out_size || out.overflow_get()) { return(false); }3435return(true);36}37catch (...)38{39return(false);40}41}4243bool decompress_lzma_7z(const unsigned char* in_data, unsigned int in_size, unsigned char* out_data, unsigned int out_size) throw ()44{45ISequentialInStream_Array in(reinterpret_cast<const char*>(in_data), in_size);46ISequentialOutStream_Array out(reinterpret_cast<char*>(out_data), out_size);4748return(decompress_lzma_7z(in, in_size, out, out_size));49}505152