Subversion Repositories spk

Rev

Rev 96 | Rev 116 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 96 Rev 115
Line 24... Line 24...
24
#include "secure.h"
24
#include "secure.h"
25
 
25
 
26
// LZMA compression
26
// LZMA compression
27
#include "lzma/Lzma86Enc.h"
27
#include "lzma/Lzma86Enc.h"
28
#include "lzma/Lzma86Dec.h"
28
#include "lzma/Lzma86Dec.h"
-
 
29
 
-
 
30
// X2BOD
-
 
31
/*
-
 
32
#include "x2bc/x2bc_common/settings.h"
-
 
33
#include "x2bc/x2bc_common/bob_dom.h"
-
 
34
#include "x2bc/x2bc_common/bod_parser.h"
-
 
35
#include "x2bc/x2bc_common/realfile_stream.h"
-
 
36
*/
-
 
37
#include "../Windows/libx2bc.h"
29
 
38
 
30
//////////////////////////////////////////////////////////////////////
39
//////////////////////////////////////////////////////////////////////
31
// Construction/Destruction
40
// Construction/Destruction
32
//////////////////////////////////////////////////////////////////////
41
//////////////////////////////////////////////////////////////////////
33
 
42
 
Line 873... Line 882...
873
	if ( (!m_sData) || (!m_lDataSize) ) {
882
	if ( (!m_sData) || (!m_lDataSize) ) {
874
		return (m_lSize) ? false : true;
883
		return (m_lSize) ? false : true;
875
	}
884
	}
876
 
885
 
877
	if ( m_bCompressedToFile )
886
	if ( m_bCompressedToFile )
878
		return false;
887
		return false;
879
 
888
 
880
	// if comopression is set to none, dont bother
889
	// if comopression is set to none, dont bother
881
	if ( m_iDataCompression == SPKCOMPRESS_NONE )
890
	if ( m_iDataCompression == SPKCOMPRESS_NONE )
882
		return true;
891
		return true;
883
 
892
 
884
	if ( m_iDataCompression == SPKCOMPRESS_ZLIB )
893
	if ( m_iDataCompression == SPKCOMPRESS_ZLIB )
885
	{
894
	{
886
		unsigned long uncomprLen = m_lUncomprDataSize;
895
		unsigned long uncomprLen = m_lUncomprDataSize;
887
		unsigned char *uncompr = new unsigned char[m_lUncomprDataSize];
896
		unsigned char *uncompr = new unsigned char[m_lUncomprDataSize];
888
		int err = uncompress ( uncompr, &uncomprLen, (const unsigned char *)m_sData, m_lDataSize );
897
		int err = uncompress ( uncompr, &uncomprLen, (const unsigned char *)m_sData, m_lDataSize );
889
		if ( err == Z_OK )
898
		if ( err == Z_OK )
Line 1306... Line 1315...
1306
		case SPKINSTALL_UNINSTALL_COPY:
1315
		case SPKINSTALL_UNINSTALL_COPY:
1307
			errorStr = "Coping uninstall file: %1";
1316
			errorStr = "Coping uninstall file: %1";
1308
			break;
1317
			break;
1309
		case SPKINSTALL_UNINSTALL_COPY_FAIL:
1318
		case SPKINSTALL_UNINSTALL_COPY_FAIL:
1310
			errorStr = "Unable to Copy uninstall file: %1";
1319
			errorStr = "Unable to Copy uninstall file: %1";
1311
			break;
1320
			break;
1312
		case SPKINSTALL_UNINSTALL_REMOVE:
1321
		case SPKINSTALL_UNINSTALL_REMOVE:
1313
			errorStr = "Removing Uninstall file: %1";
1322
			errorStr = "Removing Uninstall file: %1";
1314
			break;
1323
			break;
1315
		case SPKINSTALL_UNINSTALL_REMOVE_FAIL:
1324
		case SPKINSTALL_UNINSTALL_REMOVE_FAIL:
1316
			errorStr = "Unable to remove Uninstall file: %1";
1325
			errorStr = "Unable to remove Uninstall file: %1";
Line 1734... Line 1743...
1734
		return true;
1743
		return true;
1735
	else if ( ext == "pbd" )
1744
	else if ( ext == "pbd" )
1736
		return true;
1745
		return true;
1737
 
1746
 
1738
	return false;
1747
	return false;
-
 
1748
}
-
 
1749
 
-
 
1750
unsigned char *C_File::BobDecompile(size_t *size)
-
 
1751
{
-
 
1752
	(*size) = 0;
-
 
1753
 
-
 
1754
	Utils::String fromFile = this->GetFilePointer().ToString();
-
 
1755
	if ( !CFileIO::Exists(fromFile) ) {
-
 
1756
		if ( this->WriteToFile(CPackages::tempDirectory() + "bob.tmp") ) {
-
 
1757
			fromFile = CPackages::tempDirectory() + "bob.tmp";
-
 
1758
		}
-
 
1759
	}
-
 
1760
 
-
 
1761
	fromFile = fromFile.findReplace("/", "\\");
-
 
1762
	Utils::String toFile = CPackages::tempDirectory() + "bod.tmp";
-
 
1763
	toFile = toFile.findReplace("/", "\\");
-
 
1764
 
-
 
1765
	if ( CFileIO::Exists(fromFile) ) {
-
 
1766
		if ( X2BC_BOB2BOD(fromFile.c_str(), toFile.c_str()) ) {
-
 
1767
			CFileIO F(toFile);
-
 
1768
			if ( F.exists() && F.startRead() ) {
-
 
1769
				unsigned char *data = F.readAll(size);
-
 
1770
				F.close();
-
 
1771
				F.remove();
-
 
1772
 
-
 
1773
				return data;
-
 
1774
			}
-
 
1775
		}
-
 
1776
	}
-
 
1777
 
-
 
1778
	if ( CFileIO::Exists(CPackages::tempDirectory() + "bob.tmp") )
-
 
1779
		CFileIO(CPackages::tempDirectory() + "bob.tmp").remove();
-
 
1780
	/*
-
 
1781
	Settings settings;
-
 
1782
	bob_dom_document doc(&settings);
-
 
1783
	
-
 
1784
	ibinaryrealfile is;
-
 
1785
	otextrealfile os;
-
 
1786
	os.open(CPackages::tempDirectory() + "tmp.tmp", filestream::create);
-
 
1787
	is.open(this->GetFilePointer().c_str(), filestream::rdonly);
-
 
1788
	
-
 
1789
	if(is.fail() || os.fail()) return NULL;
-
 
1790
	
-
 
1791
	bool bRes=doc.convert(is, os);
-
 
1792
 
-
 
1793
	for(bob_dom_document::ErrorIterator &it=doc.errors.begin(); it!=doc.errors.end(); ++it){
-
 
1794
		//BOBError(*it);
-
 
1795
	}
-
 
1796
 
-
 
1797
	if ( bRed ) {
-
 
1798
		CFileIO F(CPackages::tempDirectory() + "tmp.tmp");
-
 
1799
		if ( F.exists() && F.startRead() ) {
-
 
1800
			unsigned char *data = F.readAll(size);
-
 
1801
			F.close();
-
 
1802
			F.remove();
-
 
1803
 
-
 
1804
			return data;
-
 
1805
		}
-
 
1806
	}
-
 
1807
*/
-
 
1808
	return NULL;
1739
}
1809
}
1740
 
1810
 
1741
bool C_File::BobDecompile()
1811
bool C_File::BobDecompile()
1742
{
1812
{
1743
	bool bRes=false;
1813
	bool bRes=false;