Subversion Repositories spk

Rev

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

Rev 277 Rev 283
Line 26... Line 26...
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
 
29
 
30
// X2BOD
30
// X2BOD
-
 
31
#ifdef _XBODLIBRARY__
-
 
32
#include "../Windows/libx2bc.h"
31
/*
33
#else
32
#include "x2bc/x2bc_common/settings.h"
34
#include "x2bc/x2bc_common/settings.h"
33
#include "x2bc/x2bc_common/bob_dom.h"
35
#include "x2bc/x2bc_common/bob_dom.h"
34
#include "x2bc/x2bc_common/bod_parser.h"
36
#include "x2bc/x2bc_common/bod_parser.h"
35
#include "x2bc/x2bc_common/realfile_stream.h"
37
#include "x2bc/x2bc_common/realfile_stream.h"
36
*/
38
#endif
37
#include "../Windows/libx2bc.h"
-
 
38
 
39
 
39
//////////////////////////////////////////////////////////////////////
40
//////////////////////////////////////////////////////////////////////
40
// STATIC FUNCTIONS
41
// STATIC FUNCTIONS
41
//////////////////////////////////////////////////////////////////////
42
//////////////////////////////////////////////////////////////////////
42
 
43
 
Line 139... Line 140...
139
	Reset ();
140
	Reset ();
140
	setFilename(filename);
141
	setFilename(filename);
141
}
142
}
142
 
143
 
143
C_File::~C_File()
144
C_File::~C_File()
144
{
145
{
145
	DeleteData ();
146
	DeleteData ();
146
	if (!_sTmpFile.empty())
147
	if (!_sTmpFile.empty())
147
		CFileIO::Remove(_sTmpFile);
148
		CFileIO::Remove(_sTmpFile);
148
}
149
}
149
 
150
 
150
 
151
 
151
long C_File::uncompressedDataSize() const
152
long C_File::uncompressedDataSize() const
152
{
153
{
153
	if (m_lUncomprDataSize)
154
	if (m_lUncomprDataSize)
154
		return m_lUncomprDataSize;
155
		return m_lUncomprDataSize;
Line 169... Line 170...
169
 
170
 
170
	Utils::WString sDir = _sDir;
171
	Utils::WString sDir = _sDir;
171
 
172
 
172
	if ((m_iFileType == FILETYPE_MOD) && (sDir == L"Patch"))
173
	if ((m_iFileType == FILETYPE_MOD) && (sDir == L"Patch"))
173
		return L"PluginManager/Patch";
174
		return L"PluginManager/Patch";
174
 
175
 
175
	if ((!sDir.empty()) && (m_iFileType != FILETYPE_README) && sDir != L".")
176
	if ((!sDir.empty()) && (m_iFileType != FILETYPE_README) && sDir != L".")
176
	{
177
	{
177
		Utils::WString dir = sDir.findReplace(L"\\", L"/");
178
		Utils::WString dir = sDir.findReplace(L"\\", L"/");
178
		if (file)
179
		if (file)
179
		{
180
		{
Line 255... Line 256...
255
 
256
 
256
		// script files need to check
257
		// script files need to check
257
		case FILETYPE_SCRIPT:
258
		case FILETYPE_SCRIPT:
258
		case FILETYPE_UNINSTALL:
259
		case FILETYPE_UNINSTALL:
259
			m_bSigned = this->ReadSignedFile();
260
			m_bSigned = this->ReadSignedFile();
260
			break;
261
			break;
261
 
262
 
262
		// mission files
263
		// mission files
263
		case FILETYPE_MISSION:
264
		case FILETYPE_MISSION:
264
			m_bSigned = false;
265
			m_bSigned = false;
265
			break;
266
			break;
266
	}
267
	}
Line 821... Line 822...
821
			break;
822
			break;
822
 
823
 
823
		case SPKCOMPRESS_LZMA:
824
		case SPKCOMPRESS_LZMA:
824
			{
825
			{
825
				unsigned char *compr = (unsigned char *)malloc(comprLen);
826
				unsigned char *compr = (unsigned char *)malloc(comprLen);
-
 
827
				if (!compr) {
-
 
828
					return NULL;
-
 
829
				}
826
				SRes res = Lzma86_Encode((Byte *)compr, (size_t *)&comprLen, (const Byte *)m_sData, (size_t)m_lDataSize, level, LZMA_DICT, SZ_FILTER_NO, (progress) ? progress->GetDonePointer() : NULL);
830
				SRes res = Lzma86_Encode((Byte *)compr, (size_t *)&comprLen, (const Byte *)m_sData, (size_t)m_lDataSize, level, LZMA_DICT, SZ_FILTER_NO, (progress) ? progress->GetDonePointer() : NULL);
827
 
831
 
828
				if ( res == SZ_OK )
832
				if ( res == SZ_OK )
829
				{
833
				{
830
					unsigned char *retData = new unsigned char[comprLen];
834
					unsigned char *retData = new unsigned char[comprLen];
831
					(*outSize) = comprLen;
835
					(*outSize) = comprLen;
832
					memcpy(retData, compr, comprLen);
836
					memcpy(retData, compr, comprLen);
Line 836... Line 840...
836
 
840
 
837
				free(compr);
841
				free(compr);
838
				return NULL;
842
				return NULL;
839
			}
843
			}
840
			break;
844
			break;
841
	}
845
	}
842
 
846
 
843
	return NULL;
847
	return NULL;
844
}
848
}
845
 
849
 
846
bool C_File::CompressData ( int compressionType, CProgressInfo *progress, int level )
850
bool C_File::CompressData ( int compressionType, CProgressInfo *progress, int level )
847
{
851
{
848
	// no data to try to compress
852
	// no data to try to compress
849
	if ( (!m_sData) || (!m_lDataSize) )
853
	if ( (!m_sData) || (!m_lDataSize) )
850
		return false;
854
		return false;
851
 
855
 
852
	// if comopression is set to noe, dont bother
856
	// if comopression is set to noe, dont bother
853
	if ( compressionType == SPKCOMPRESS_NONE )
857
	if (compressionType == SPKCOMPRESS_NONE)
854
		return true;
858
		return true;
855
 
859
 
856
	if ( compressionType == SPKCOMPRESS_7ZIP )
860
	if ( compressionType == SPKCOMPRESS_7ZIP )
857
		compressionType = SPKCOMPRESS_LZMA;
861
		compressionType = SPKCOMPRESS_LZMA;
858
 
862
 
859
	// if its zlib, and we are trying to compress pcked files (ie already zlib compression) then switch to lzma instead
863
	// if its zlib, and we are trying to compress pcked files (ie already zlib compression) then switch to lzma instead
860
	if ( compressionType == SPKCOMPRESS_ZLIB && (this->checkFileExt(L"pck") || this->checkFileExt(L"cat") || this->checkFileExt(L"dat") || this->checkFileExt(L"pbb") || this->checkFileExt(L"pbd")) )
864
	if ( compressionType == SPKCOMPRESS_ZLIB && (this->checkFileExt(L"pck") || this->checkFileExt(L"cat") || this->checkFileExt(L"dat") || this->checkFileExt(L"pbb") || this->checkFileExt(L"pbd")) )
861
		compressionType = SPKCOMPRESS_LZMA;
865
		compressionType = SPKCOMPRESS_LZMA;
-
 
866
 
-
 
867
	// dont compress cat/dat files
-
 
868
	if (this->checkFileExt(L"cat") || this->checkFileExt(L"dat"))
-
 
869
		compressionType = SPKCOMPRESS_NONE;
862
 
870
 
863
	// if its already compressed, no need to compress again
871
	// if its already compressed, no need to compress again
864
	if ( compressionType == m_iDataCompression )
872
	if ( compressionType == m_iDataCompression )
865
		return true;
873
		return true;
866
 
874
 
Line 932... Line 940...
932
			m_bUsedMalloc = false;
940
			m_bUsedMalloc = false;
933
			m_lDataSize = comprLen;
941
			m_lDataSize = comprLen;
934
			m_iDataCompression = compressionType;
942
			m_iDataCompression = compressionType;
935
		}
943
		}
936
		// we shall always return true, files can be added in non compressed mode
944
		// we shall always return true, files can be added in non compressed mode
-
 
945
		//TODO: file compression?
937
		return true;
946
		return true;
938
	}
947
	}
939
 
948
 
940
	return false;
949
	return false;
941
}
950
}
Line 946... Line 955...
946
	if ( (!m_sData) || (!m_lDataSize) ) {
955
	if ( (!m_sData) || (!m_lDataSize) ) {
947
		return (m_lSize) ? false : true;
956
		return (m_lSize) ? false : true;
948
	}
957
	}
949
 
958
 
950
	if ( m_bCompressedToFile )
959
	if ( m_bCompressedToFile )
951
		return false;
960
		return false;
952
 
961
 
953
	// if comopression is set to none, dont bother
962
	// if comopression is set to none, dont bother
954
	if ( m_iDataCompression == SPKCOMPRESS_NONE )
963
	if ( m_iDataCompression == SPKCOMPRESS_NONE )
955
		return true;
964
		return true;
956
 
965
 
957
	if ( m_iDataCompression == SPKCOMPRESS_ZLIB )
966
	if ( m_iDataCompression == SPKCOMPRESS_ZLIB )
Line 1408... Line 1417...
1408
	return ret;
1417
	return ret;
1409
}
1418
}
1410
 
1419
 
1411
 
1420
 
1412
bool C_File::CheckPCK ()
1421
bool C_File::CheckPCK ()
1413
{
1422
{
1414
	if ( (m_sData) && (m_lDataSize) && (m_iDataCompression == SPKCOMPRESS_NONE) )
1423
	if ( (m_sData) && (m_lDataSize) && (m_iDataCompression == SPKCOMPRESS_NONE) )
1415
		return IsDataPCK ( m_sData, m_lDataSize );
1424
		return IsDataPCK ( m_sData, m_lDataSize );
1416
 
1425
 
1417
	Utils::WString filename = filePointer();
1426
	Utils::WString filename = filePointer();
1418
	if ( !filename.empty() ) {
1427
	if ( !filename.empty() ) {
1419
		CFileIO File(filename);
1428
		CFileIO File(filename);
1420
		if ( File.startRead() ) {
1429
		if ( File.startRead() ) {
1421
			unsigned char data[4];
1430
			unsigned char data[4];
1422
			if ( File.read(data, 3) ) return IsDataPCK ( data, 3 );
1431
			if ( File.read(data, 3) ) return IsDataPCK ( data, 3 );
1423
		}
1432
		}
1424
	}
1433
	}
1425
 
1434
 
1426
	if (checkFileExt(L"pck") || checkFileExt(L"pbb") || checkFileExt(L"pbd")) return true;
1435
	if (checkFileExt(L"pck") || checkFileExt(L"pbb") || checkFileExt(L"pbd")) return true;
1427
	return false;
1436
	return false;
1428
}
1437
}
1429
 
1438
 
1430
bool C_File::PCKFile()
1439
bool C_File::PCKFile()
1431
{
1440
{
1432
	if ( !m_lDataSize || !m_sData )
1441
	if ( !m_lDataSize || !m_sData )
1433
	{
1442
	{
1434
		if ( !this->ReadFromFile() )
1443
		if ( !this->ReadFromFile() )
1435
			return false;
1444
			return false;
1436
	}
1445
	}
1437
 
1446
 
1438
	if ( m_lDataSize && m_sData )
1447
	if ( m_lDataSize && m_sData )
1439
	{
1448
	{
1440
		if ( !this->UncompressData() )
1449
		if ( !this->UncompressData() )
1441
			return false;
1450
			return false;
1442
 
1451
 
1443
		size_t size;
1452
		size_t size;
1444
		unsigned char *data = PCKData(m_sData, m_lDataSize, &size, false);
1453
		unsigned char *data = PCKData(m_sData, m_lDataSize, &size, false);
1445
		if ( data && size )
1454
		if ( data && size )
1446
		{
1455
		{
Line 1493... Line 1502...
1493
}
1502
}
1494
 
1503
 
1495
bool C_File::UnPCKFile()
1504
bool C_File::UnPCKFile()
1496
{
1505
{
1497
	if ( !m_lDataSize || !m_sData )
1506
	if ( !m_lDataSize || !m_sData )
1498
	{
1507
	{
1499
		if ( !this->ReadFromFile() )
1508
		if ( !this->ReadFromFile() )
1500
			return false;
1509
			return false;
1501
	}
1510
	}
1502
	if ( m_lDataSize && m_sData )
1511
	if ( m_lDataSize && m_sData )
1503
	{
1512
	{
Line 1551... Line 1560...
1551
	{
1560
	{
1552
		tempData = new unsigned char[datasize]; 
1561
		tempData = new unsigned char[datasize]; 
1553
		newData = tempData;
1562
		newData = tempData;
1554
		memcpy(newData, data, datasize);
1563
		memcpy(newData, data, datasize);
1555
		unsigned char magic = newData[0] ^ 0xC8;
1564
		unsigned char magic = newData[0] ^ 0xC8;
1556
 
1565
 
1557
		for ( size_t i = 1; i < datasize; i++ )
1566
		for ( size_t i = 1; i < datasize; i++ )
1558
			newData[i] ^= magic;
1567
			newData[i] ^= magic;
1559
		++newData;
1568
		++newData;
1560
		--datasize;
1569
		--datasize;
1561
	}
1570
	}
Line 1608... Line 1617...
1608
	{
1617
	{
1609
		if ( tempData ) delete []tempData;
1618
		if ( tempData ) delete []tempData;
1610
		delete uncompr;
1619
		delete uncompr;
1611
		*len = 0;
1620
		*len = 0;
1612
		return NULL;
1621
		return NULL;
1613
	}
1622
	}
1614
 
1623
 
1615
	*len = uncomprLen;
1624
	*len = uncomprLen;
1616
	uncompr[uncomprLen] = '\0';
1625
	uncompr[uncomprLen] = '\0';
1617
	if ( tempData ) delete []tempData;
1626
	if ( tempData ) delete []tempData;
1618
	return uncompr;
1627
	return uncompr;
1619
}
1628
}
1620
 
1629
 
1621
bool IsDataPCK ( const unsigned char *data, size_t size )
1630
bool IsDataPCK ( const unsigned char *data, size_t size )
1622
{
1631
{
1623
	if ( size >=3 )
1632
	if ( size >=3 )
1624
	{
1633
	{
1625
		unsigned char magic=data[0] ^ 0xC8;
1634
		unsigned char magic=data[0] ^ 0xC8;
Line 1637... Line 1646...
1637
	if ( IsDataPCK ( data, size ) ) {
1646
	if ( IsDataPCK ( data, size ) ) {
1638
		size_t unpckSize = 0;
1647
		size_t unpckSize = 0;
1639
		unsigned char *unpckData = UnPCKData ( data, size, &unpckSize, false );
1648
		unsigned char *unpckData = UnPCKData ( data, size, &unpckSize, false );
1640
		if ( (unpckData) && (unpckSize) ) {
1649
		if ( (unpckData) && (unpckSize) ) {
1641
			ret = ReadSignedFromData ( unpckData, (long)unpckSize );
1650
			ret = ReadSignedFromData ( unpckData, (long)unpckSize );
1642
			delete unpckData;
1651
			delete unpckData;
1643
		}
1652
		}
1644
		return ret;
1653
		return ret;
1645
	}
1654
	}
1646
 
1655
 
1647
	char tag[10000];
1656
	char tag[10000];
1648
 
1657
 
1649
	// work backwards
1658
	// work backwards
1650
	int pos = size - 1;
1659
	int pos = size - 1;
1651
	int max = size - 5000;
1660
	int max = size - 5000;
1652
	if ( max < 0 ) max = 0;
1661
	if ( max < 0 ) max = 0;
1653
	// find the first tage
1662
	// find the first tage
Line 1657... Line 1666...
1657
 
1666
 
1658
		// now find the front
1667
		// now find the front
1659
		int pos2 = pos - 1;
1668
		int pos2 = pos - 1;
1660
		while ( data[pos2] != '<' && pos2 > max ) pos2--;
1669
		while ( data[pos2] != '<' && pos2 > max ) pos2--;
1661
		if ( data[pos2] != '<' ) break;
1670
		if ( data[pos2] != '<' ) break;
1662
 
1671
 
1663
		memcpy(tag, data + pos2, pos - pos2);
1672
		memcpy(tag, data + pos2, pos - pos2);
1664
		tag[pos - pos2] = '\0';
1673
		tag[pos - pos2] = '\0';
1665
 
1674
 
1666
		Utils::WString sTag(tag);
1675
		Utils::WString sTag(tag);
1667
		if ( sTag.Compare(L"</signature") || sTag.Compare(L"<signature") ) return true;
1676
		if ( sTag.Compare(L"</signature") || sTag.Compare(L"<signature") ) return true;
1668
		if ( sTag.Compare(L"</codearray") || sTag.Compare(L"<codearray") ) return false;
1677
		if ( sTag.Compare(L"</codearray") || sTag.Compare(L"<codearray") ) return false;
1669
		pos = pos2 - 1;
1678
		pos = pos2 - 1;
1670
	}
1679
	}
1671
 
1680
 
1672
	return false;
1681
	return false;
1673
}
1682
}
1674
 
1683
 
1675
int ReadScriptVersionFromData ( unsigned char *data, long size )
1684
int ReadScriptVersionFromData ( unsigned char *data, long size )
1676
{
1685
{
1677
	int iVersion = 0;
1686
	int iVersion = 0;
Line 1725... Line 1734...
1725
 
1734
 
1726
	return iVersion;
1735
	return iVersion;
1727
}
1736
}
1728
 
1737
 
1729
Utils::WString C_File::baseName() const
1738
Utils::WString C_File::baseName() const
1730
{
1739
{
1731
	// remove any directory
1740
	// remove any directory
1732
	Utils::WString file = _sName.token(L"/", -1);
1741
	Utils::WString file = _sName.token(L"/", -1);
1733
 
1742
 
1734
	// remove file extension
1743
	// remove file extension
1735
	return file.remToken(L".", -1);
1744
	return file.remToken(L".", -1);
Line 1753... Line 1762...
1753
		if ( oldFile->GetData() && m_lDataSize )
1762
		if ( oldFile->GetData() && m_lDataSize )
1754
		{
1763
		{
1755
			m_sData = new unsigned char[m_lDataSize];
1764
			m_sData = new unsigned char[m_lDataSize];
1756
			m_bUsedMalloc = false;
1765
			m_bUsedMalloc = false;
1757
			memcpy((char *)m_sData, (char *)oldFile->GetData(), m_lDataSize);
1766
			memcpy((char *)m_sData, (char *)oldFile->GetData(), m_lDataSize);
1758
		}
1767
		}
1759
		m_lUncomprDataSize = oldFile->uncompressedDataSize();
1768
		m_lUncomprDataSize = oldFile->uncompressedDataSize();
1760
	}
1769
	}
1761
	m_iDataCompression = oldFile->GetCompressionType();
1770
	m_iDataCompression = oldFile->GetCompressionType();
1762
}
1771
}
1763
 
1772
 
1764
float GetLibraryVersion() { return (float)LIBRARYVERSION; }
1773
float GetLibraryVersion() { return (float)LIBRARYVERSION; }
1765
float GetFileFormatVersion() { return (float)FILEVERSION; }
1774
float GetFileFormatVersion() { return (float)FILEVERSION; }
1766
 
1775
 
1767
Utils::WString C_File::fileExt() const 
1776
Utils::WString C_File::fileExt() const 
1768
{ 
1777
{ 
1769
	return _sName.token(L".", -1); 
1778
	return _sName.token(L".", -1); 
1770
}
1779
}
1771
 
1780
 
1772
bool C_File::checkFileExt(const Utils::WString& ext) 
1781
bool C_File::checkFileExt(const Utils::WString& ext) 
1773
{
1782
{
1774
	if (fileExt().Compare(ext)) return true; return false;
1783
	if (fileExt().Compare(ext)) return true; return false;
1775
}
1784
}
1776
 
1785
 
1777
const Utils::WString &C_File::changeFileExt(const Utils::WString &ext)
1786
const Utils::WString &C_File::changeFileExt(const Utils::WString &ext)
1778
{
1787
{
Line 1782... Line 1791...
1782
 
1791
 
1783
bool C_File::CheckPackedExtension()
1792
bool C_File::CheckPackedExtension()
1784
{
1793
{
1785
	Utils::WString ext = this->fileExt();
1794
	Utils::WString ext = this->fileExt();
1786
	if ( ext == L"pck" )
1795
	if ( ext == L"pck" )
1787
		return true;
1796
		return true;
1788
	else if ( ext == L"pbb" )
1797
	else if ( ext == L"pbb" )
1789
		return true;
1798
		return true;
1790
	else if ( ext == L"pbd" )
1799
	else if ( ext == L"pbd" )
1791
		return true;
1800
		return true;
1792
 
1801
 
Line 1841... Line 1850...
1841
}
1850
}
1842
 
1851
 
1843
 
1852
 
1844
unsigned char *C_File::BobDecompile(size_t *size)
1853
unsigned char *C_File::BobDecompile(size_t *size)
1845
{
1854
{
-
 
1855
 
-
 
1856
	(*size) = 0;
-
 
1857
 
-
 
1858
	Utils::WString fromFile = this->filePointer();
-
 
1859
	if (!CFileIO::Exists(fromFile))
-
 
1860
	{
-
 
1861
		if (this->writeToFile(CPackages::tempDirectory() + L"bob.tmp"))
-
 
1862
			fromFile = CPackages::tempDirectory() + L"bob.tmp";
-
 
1863
	}
-
 
1864
 
-
 
1865
	fromFile = fromFile.findReplace(L"/", L"\\");
-
 
1866
	Utils::WString toFile = CPackages::tempDirectory() + L"bod.tmp";
-
 
1867
	toFile = toFile.findReplace(L"/", L"\\");
-
 
1868
 
-
 
1869
	if (CFileIO::Exists(fromFile))
-
 
1870
	{
-
 
1871
#ifdef _XBODLIBRARY__
-
 
1872
		if (X2BC_BOB2BOD(fromFile.toString().c_str(), toFile.toString().c_str())) {
-
 
1873
			CFileIO F(toFile);
-
 
1874
			if (F.exists() && F.startRead()) {
-
 
1875
				unsigned char* data = F.readAll(size);
-
 
1876
				F.close();
-
 
1877
				F.remove();
-
 
1878
 
-
 
1879
				return data;
-
 
1880
			}
-
 
1881
		}
-
 
1882
#else
-
 
1883
		// Use x2bc library to convert the file
-
 
1884
		Settings settings;
-
 
1885
		bob_dom_document doc(&settings);
-
 
1886
 
-
 
1887
		ibinaryrealfile is;
-
 
1888
		otextrealfile os;
-
 
1889
 
-
 
1890
		is.open(fromFile.toString().c_str(), filestream::rdonly);
-
 
1891
		os.open(toFile.toString().c_str(), filestream::create);
-
 
1892
 
-
 
1893
		if (!is.fail() && !os.fail())
-
 
1894
		{
-
 
1895
			if (doc.convert(is, os))
-
 
1896
			{
-
 
1897
				CFileIO F(toFile);
-
 
1898
				if (F.exists() && F.startRead())
-
 
1899
				{
-
 
1900
					unsigned char* data = F.readAll(size);
-
 
1901
					F.close();
-
 
1902
					F.remove();
-
 
1903
 
-
 
1904
					return data;
-
 
1905
				}
-
 
1906
			}
-
 
1907
		}
-
 
1908
#endif
-
 
1909
	}
-
 
1910
 
-
 
1911
	if (CFileIO::Exists(CPackages::tempDirectory() + L"bob.tmp"))
-
 
1912
		CFileIO::Remove(CPackages::tempDirectory() + L"bob.tmp");
-
 
1913
 
-
 
1914
	return NULL;
-
 
1915
	/*
1846
	(*size) = 0;
1916
	(*size) = 0;
1847
 
1917
 
1848
	Utils::WString fromFile = this->filePointer();
1918
	Utils::WString fromFile = this->filePointer();
1849
	if ( !CFileIO::Exists(fromFile) ) {
1919
	if ( !CFileIO::Exists(fromFile) ) {
1850
		if ( this->writeToFile(CPackages::tempDirectory() + L"bob.tmp")) {
1920
		if ( this->writeToFile(CPackages::tempDirectory() + L"bob.tmp")) {
1851
			fromFile = CPackages::tempDirectory() + L"bob.tmp";
1921
			fromFile = CPackages::tempDirectory() + L"bob.tmp";
1852
		}
1922
		}
1853
	}
1923
	}
1854
 
1924
 
1855
	fromFile = fromFile.findReplace(L"/", L"\\");
1925
	fromFile = fromFile.findReplace(L"/", L"\\");
1856
	Utils::WString toFile = CPackages::tempDirectory() + L"bod.tmp";
1926
	Utils::WString toFile = CPackages::tempDirectory() + L"bod.tmp";
1857
	toFile = toFile.findReplace(L"/", L"\\");
1927
	toFile = toFile.findReplace(L"/", L"\\");
Line 1861... Line 1931...
1861
			CFileIO F(toFile);
1931
			CFileIO F(toFile);
1862
			if ( F.exists() && F.startRead() ) {
1932
			if ( F.exists() && F.startRead() ) {
1863
				unsigned char *data = F.readAll(size);
1933
				unsigned char *data = F.readAll(size);
1864
				F.close();
1934
				F.close();
1865
				F.remove();
1935
				F.remove();
1866
 
1936
 
1867
				return data;
1937
				return data;
1868
			}
1938
			}
1869
		}
1939
		}
1870
	}
1940
	}
1871
 
1941
 
1872
	if ( CFileIO::Exists(CPackages::tempDirectory() + L"bob.tmp") )
1942
	if ( CFileIO::Exists(CPackages::tempDirectory() + L"bob.tmp") )
1873
		CFileIO::Remove(CPackages::tempDirectory() + L"bob.tmp");
1943
		CFileIO::Remove(CPackages::tempDirectory() + L"bob.tmp");
-
 
1944
		*/
-
 
1945
 
-
 
1946
 
1874
	/*
1947
	/*
1875
	Settings settings;
1948
	Settings settings;
1876
	bob_dom_document doc(&settings);
1949
	bob_dom_document doc(&settings);
1877
	
1950
	
1878
	ibinaryrealfile is;
1951
	ibinaryrealfile is;