Subversion Repositories spk

Rev

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

Rev 50 Rev 51
Line 216... Line 216...
216
	}
216
	}
217
	m_lWares.push_back ( ware );
217
	m_lWares.push_back ( ware );
218
	m_pLastWare = ware;
218
	m_pLastWare = ware;
219
 
219
 
220
	_changed();
220
	_changed();
221
}
-
 
222
 
-
 
223
 
-
 
224
 
-
 
225
bool CSpkFile::ReadFileToMemory ( C_File *file )
-
 
226
{
-
 
227
	if ( !file )
-
 
228
		return false;
-
 
229
 
-
 
230
	// check if data is already extracted
-
 
231
	if ( (file->GetDataSize ()) && (file->GetData()) )
-
 
232
		return true;
-
 
233
 
-
 
234
	// no file to read from
-
 
235
	if ( this->filename().empty() )
-
 
236
		return false;
-
 
237
 
-
 
238
	// now open the file
-
 
239
	FILE *id = fopen ( this->filename().c_str(), "rb" );
-
 
240
	if ( !id )
-
 
241
		return false;
-
 
242
 
-
 
243
	// read the header
-
 
244
	GetEndOfLine ( id, NULL, false );
-
 
245
	// skip past values
-
 
246
	fseek ( id, m_SHeader.lValueCompressSize, SEEK_CUR );
-
 
247
 
-
 
248
	// read the next header
-
 
249
	GetEndOfLine ( id, NULL, false );
-
 
250
	// skip past files
-
 
251
	fseek ( id, 4, SEEK_CUR );
-
 
252
	fseek ( id, m_SHeader2.lSize, SEEK_CUR );
-
 
253
 
-
 
254
	// skip the icon file
-
 
255
	if ( m_pIconFile )
-
 
256
	{
-
 
257
		fseek ( id, 4, SEEK_CUR );
-
 
258
		fseek ( id, m_pIconFile->GetDataSize (), SEEK_CUR );
-
 
259
	}
-
 
260
 
-
 
261
	// now were in the file section
-
 
262
	// skip past each one
-
 
263
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
-
 
264
	{
-
 
265
		C_File *fit = node->Data();
-
 
266
		if ( fit == file )
-
 
267
			break;
-
 
268
 
-
 
269
		fseek ( id, 4, SEEK_CUR );
-
 
270
		fseek ( id, fit->GetDataSize(), SEEK_CUR );
-
 
271
	}
-
 
272
 
-
 
273
	// now we should be at the start of the file
-
 
274
	// read the data into memory
-
 
275
	if ( !file->ReadFromFile ( id, file->GetDataSize() ) )
-
 
276
	{
-
 
277
		fclose ( id );
-
 
278
		return false;
-
 
279
	}
-
 
280
	fclose ( id );
-
 
281
 
-
 
282
	return true;
-
 
283
}
221
}
284
 
222
 
285
bool CSpkFile::CheckValidReadmes () const
223
bool CSpkFile::CheckValidReadmes () const
286
{
224
{
287
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
225
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
288
	{
226
	{
289
		C_File *file = node->Data();
227
		C_File *file = node->Data();
290
		if ( file->GetFileType() != FILETYPE_README )
228
		if ( file->GetFileType() != FILETYPE_README )
291
			continue;
229
			continue;
292
		if ( !file->CheckValidFilePointer() )
230
		if ( !file->CheckValidFilePointer() )
293
			continue;
231
			continue;
294
		return true;
232
		return true;
295
	}
233
	}
296
 
234
 
297
	return false;
235
	return false;
298
}
236
}
299
 
-
 
300
 
-
 
301
 
237
 
302
void CSpkFile::ClearWares()
238
void CSpkFile::ClearWares()
303
{
239
{
304
	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
240
	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
305
		node->Data()->lText.clear(true);
241
		node->Data()->lText.clear(true);