Subversion Repositories spk

Rev

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

Rev 279 Rev 281
Line 9561... Line 9561...
9561
	else
9561
	else
9562
		archive = new CSpkFile(); // converting to a spk file
9562
		archive = new CSpkFile(); // converting to a spk file
9563
 
9563
 
9564
	GetZipItem(hz, -1, &ze);
9564
	GetZipItem(hz, -1, &ze);
9565
	int numitems = ze.index;
9565
	int numitems = ze.index;
-
 
9566
 
-
 
9567
	std::set<unsigned int> games;
9566
 
9568
 
9567
	bool error = false;
9569
	bool error = false;
9568
	for ( int zi = 0; zi < numitems; zi++ )
9570
	for ( int zi = 0; zi < numitems; zi++ )
9569
	{
9571
	{
9570
		ZIPENTRY ze;
9572
		ZIPENTRY ze;
9571
		if ( GetZipItem(hz, zi, &ze) != Z_OK )
9573
		if ( GetZipItem(hz, zi, &ze) != Z_OK )
9572
		{
9574
		{
9573
			error = true;
9575
			error = true;
9574
			break;
9576
			break;
9575
		}
9577
		}
9576
 
9578
 
9577
		if ( ze.attr & FILE_ATTRIBUTE_DIRECTORY )
9579
		if ( ze.attr & FILE_ATTRIBUTE_DIRECTORY )
9578
			continue; // dont do directories
9580
			continue; // dont do directories
9579
 
9581
 
9580
 
9582
 
Line 9596... Line 9598...
9596
 
9598
 
9597
			C_File *f = NULL;
9599
			C_File *f = NULL;
9598
 
9600
 
9599
			Utils::WString filename = CFileIO(Name).filename();
9601
			Utils::WString filename = CFileIO(Name).filename();
9600
			Utils::WString dir = CFileIO(Name).dir();
9602
			Utils::WString dir = CFileIO(Name).dir();
9601
 
9603
 
9602
			// check for special file types
9604
			// check for special file types
9603
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9605
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9604
				f = archive->addFile(filename, dir, FILETYPE_SCRIPT);
9606
				f = archive->addFile(filename, dir, FILETYPE_SCRIPT);
9605
				if ( f ) {
9607
				if ( f ) {
9606
					f->copyData((const unsigned char *)iBuf, ze.unc_size);
9608
					f->copyData((const unsigned char *)iBuf, ze.unc_size);
9607
				}
9609
				}
9608
				type = FILETYPE_UNINSTALL;
9610
				type = FILETYPE_UNINSTALL;
9609
			}
9611
			}
9610
 
9612
 
9611
			int game = 0;
9613
			int game = 0;
9612
			// check for addons
9614
			// check for addons
9613
			if (!dir.empty())
9615
			if (!dir.empty())
9614
			{
9616
			{
9615
				Utils::WString first = dir.token(L"/", 1);
9617
				Utils::WString first = dir.token(L"/", 1);
9616
				int g = m_gameExe.findAddonType(first);
9618
				int g = m_gameExe.findAddonType(first);
9617
				if (g != -1)
9619
				if (g != -1)
-
 
9620
				{
9618
					game = g + 1;
9621
					game = g + 1;
-
 
9622
					games.insert(game);
-
 
9623
				}
9619
			}
9624
			}
9620
 
9625
 
-
 
9626
			// TODO: Check if an existing file exists with a different game
9621
			if ( type == -1 )
9627
			if ( type == -1 )
9622
				f = archive->addFile(filename, dir, FILETYPE_EXTRA, 1 << game);
9628
				f = archive->addFile(filename, dir, FILETYPE_EXTRA, game > 0 ? 1 << game : 0);
9623
			else
9629
			else
9624
				f = archive->addFile(filename, extradir, static_cast<FileType>(type), 1 << game);
9630
				f = archive->addFile(filename, extradir, static_cast<FileType>(type), game > 0 ? 1 << game : 0);
-
 
9631
 
-
 
9632
			if (f)
-
 
9633
			{
-
 
9634
				if (!game && f->isFileInAddon())
-
 
9635
					games.insert(1);
9625
 
9636
 
9626
			if ( f )
-
 
9627
				f->SetData((const unsigned char *)iBuf, ze.unc_size);
9637
				f->SetData((const unsigned char*)iBuf, ze.unc_size);
-
 
9638
			}
9628
			else
9639
			else
9629
				delete[] iBuf;
9640
				delete[] iBuf;
9630
		}
9641
		}
9631
	}
9642
	}
9632
 
9643
 
9633
	CloseZip(hz);
9644
	CloseZip(hz);
9634
 
9645
 
9635
	if ( error )
9646
	if ( error )
9636
	{
9647
	{
9637
		delete archive;
9648
		delete archive;
9638
		archive = NULL;
9649
		archive = NULL;
9639
	}
9650
	}
-
 
9651
 
-
 
9652
	// if there is only one game, then set all the files to "All Games"
-
 
9653
	//if (games.size() <= 1)
-
 
9654
	{
-
 
9655
		for (auto itr = archive->fileList().Front(); itr; itr = itr->next())
-
 
9656
			itr->Data()->setGame(0);
-
 
9657
	}
-
 
9658
 
9640
	return archive;
9659
	return archive;
9641
}
9660
}
9642
 
9661
 
9643
CBaseFile *CPackages::createFromArchive(const Utils::WString &filename, bool toInstall) const
9662
CBaseFile *CPackages::createFromArchive(const Utils::WString &filename, bool toInstall) const
9644
{
9663
{