Subversion Repositories spk

Rev

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

Rev 102 Rev 109
Line 11... Line 11...
11
#include "spk.h"
11
#include "spk.h"
12
 
12
 
13
#include "DirIO.h"
13
#include "DirIO.h"
14
#include "File_IO.h"
14
#include "File_IO.h"
15
#include "CatFile.h"
15
#include "CatFile.h"
16
#include "archive/zip.h"
-
 
17
#include "Packages.h"
16
#include "Packages.h"
18
#include "TextDB.h"
17
#include "TextDB.h"
19
 
18
 
20
#include <Package/InstallText.h>
19
#include <Package/InstallText.h>
21
 
20
 
Line 1600... Line 1599...
1600
 
1599
 
1601
	File.close();
1600
	File.close();
1602
	return ret;
1601
	return ret;
1603
}
1602
}
1604
 
1603
 
1605
int CBaseFile::_read_Header(std::fstream &stream, int iReadType, int iMaxProgress, CProgressInfo *pProgress)
1604
int CBaseFile::_read_Header(CFileIO &File, int iReadType, int iMaxProgress, CProgressInfo *pProgress)
1606
{
1605
{
1607
	int doneLen = 0;
1606
	int doneLen = 0;
1608
 
1607
 
1609
	// read data to memory
1608
	// read data to memory
1610
	unsigned char *readData;
1609
	unsigned char *readData;
Line 1615... Line 1614...
1615
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
1614
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
1616
		return -1;
1615
		return -1;
1617
	}
1616
	}
1618
 
1617
 
1619
	unsigned char size[4];
1618
	unsigned char size[4];
1620
	stream.read((char *)size, 4);
1619
	File.read(size, 4);
1621
	stream.read((char *)readData, m_SHeader.lValueCompressSize);
1620
	File.read(readData, m_SHeader.lValueCompressSize);
1622
 
1621
 
1623
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1622
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1624
 
1623
 
1625
	// check for zlib compression
1624
	// check for zlib compression
1626
	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
1625
	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
Line 1655... Line 1654...
1655
	delete []readData;
1654
	delete []readData;
1656
 
1655
 
1657
	return doneLen;
1656
	return doneLen;
1658
}
1657
}
1659
 
1658
 
1660
int CBaseFile::_read_FileHeader(std::fstream &stream, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress)
1659
int CBaseFile::_read_FileHeader(CFileIO &File, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress)
1661
{
1660
{
1662
	unsigned char *readData;
1661
	unsigned char *readData;
1663
	try {
1662
	try {
1664
		readData = new unsigned char[m_SHeader2.lSize];
1663
		readData = new unsigned char[m_SHeader2.lSize];
1665
	}
1664
	}
Line 1667... Line 1666...
1667
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [header], %d (%s)", m_SHeader2.lSize, e.what());
1666
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [header], %d (%s)", m_SHeader2.lSize, e.what());
1668
		return -1;
1667
		return -1;
1669
	}
1668
	}
1670
 
1669
 
1671
	unsigned char size[4];
1670
	unsigned char size[4];
1672
	stream.read((char *)size, 4);
1671
	File.read(size, 4);
1673
	stream.read((char *)readData, m_SHeader2.lSize);
1672
	File.read(readData, m_SHeader2.lSize);
1674
 
1673
 
1675
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1674
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1676
 
1675
 
1677
	// check for zlib compression
1676
	// check for zlib compression
1678
	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
1677
	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
Line 1720... Line 1719...
1720
	int maxProgress = (readtype == SPKREAD_VALUES) ? 3 : 6;
1719
	int maxProgress = (readtype == SPKREAD_VALUES) ? 3 : 6;
1721
	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(1, maxProgress);
1720
	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(1, maxProgress);
1722
 
1721
 
1723
	long doneLen = 0;
1722
	long doneLen = 0;
1724
	// next read the data values for the spk files
1723
	// next read the data values for the spk files
1725
	if ( m_SHeader.lValueCompressSize ) doneLen = this->_read_Header(File.stream(), readtype, maxProgress, progress);
1724
	if ( m_SHeader.lValueCompressSize ) doneLen = this->_read_Header(File, readtype, maxProgress, progress);
1726
 
1725
 
1727
	// update the progress for each section
1726
	// update the progress for each section
1728
	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(3, maxProgress);
1727
	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(3, maxProgress);
1729
	if ( readtype == SPKREAD_VALUES ) return true;
1728
	if ( readtype == SPKREAD_VALUES ) return true;
1730
 
1729
 
Line 1739... Line 1738...
1739
	}
1738
	}
1740
 
1739
 
1741
	// update the progress for each section
1740
	// update the progress for each section
1742
	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(4, maxProgress);
1741
	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(4, maxProgress);
1743
 
1742
 
1744
	if ( m_SHeader2.lSize ) this->_read_FileHeader(File.stream(), readtype, maxProgress, doneLen, progress);
1743
	if ( m_SHeader2.lSize ) this->_read_FileHeader(File, readtype, maxProgress, doneLen, progress);
1745
 
1744
 
1746
	// file mismatch
1745
	// file mismatch
1747
	long numfiles = m_lFiles.size();
1746
	long numfiles = m_lFiles.size();
1748
	if ( m_pIconFile ) ++numfiles;
1747
	if ( m_pIconFile ) ++numfiles;
1749
	if ( m_SHeader2.iNumFiles != numfiles ) {
1748
	if ( m_SHeader2.iNumFiles != numfiles ) {
Line 2980... Line 2979...
2980
		// create the directory
2979
		// create the directory
2981
		wsprintf(buf, L"%hs", fname.c_str());
2980
		wsprintf(buf, L"%hs", fname.c_str());
2982
		ZipAdd(hz, buf, node->Data()->GetData(), node->Data()->GetDataSize());
2981
		ZipAdd(hz, buf, node->Data()->GetData(), node->Data()->GetDataSize());
2983
	}
2982
	}
2984
 
2983
 
-
 
2984
	// if its a ship, then add any generated files
-
 
2985
	this->addGeneratedFiles(hz);
-
 
2986
 
2985
	// add the data file
2987
	// add the data file
2986
	CyStringList list;
2988
	CyStringList list;
2987
	if ( this->GeneratePackagerScript(false, &list, true) )
2989
	if ( this->GeneratePackagerScript(false, &list, true) )
2988
	{
2990
	{
2989
		if ( CFileIO("test.tmp").WriteFile(&list) )
2991
		if ( CFileIO("test.tmp").WriteFile(&list) )