Subversion Repositories spk

Rev

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

Rev 127 Rev 129
Line 880... Line 880...
880
 
880
 
881
	spkfile.WriteFile ( filename, NULL );
881
	spkfile.WriteFile ( filename, NULL );
882
	printf ( "SPK file has been written to disk: %s\n", filename.c_str() );
882
	printf ( "SPK file has been written to disk: %s\n", filename.c_str() );
883
}
883
}
884
 
884
 
885
void ExtractFiles ( CyString sfile, CyString dir, int game )
885
void ExtractFiles (const Utils::String &sfile, const Utils::String &dir, int game )
886
{
886
{
887
	// First checks if the file exists by opening it
887
	// First checks if the file exists by opening it
888
	FILE *id = fopen ( sfile.c_str(), "rb+" );
888
	FILE *id = fopen ( sfile.c_str(), "rb+" );
889
	if ( !id )
889
	if ( !id )
890
	{
890
	{
891
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
891
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
892
		return;
892
		return;
893
	}
893
	}
894
	fclose ( id );
894
	fclose ( id );
895
 
895
 
-
 
896
	CPackages packages;
-
 
897
	packages.startup(".", ".", ".");
-
 
898
 
896
	int check = CSpkFile::CheckFile ( sfile );
899
	int check = CSpkFile::CheckFile ( sfile );
897
 
900
 
898
	// extracts a file from single packages file
901
	// extracts a file from single packages file
899
	if ( check == SPKFILE_SINGLE || check == SPKFILE_BASE || check == SPKFILE_SINGLESHIP )
902
	if ( check == SPKFILE_SINGLE || check == SPKFILE_BASE || check == SPKFILE_SINGLESHIP )
900
	{
903
	{
Line 916... Line 919...
916
			return;
919
			return;
917
		}
920
		}
918
		printf ( "(Done)\n" );
921
		printf ( "(Done)\n" );
919
 
922
 
920
		printf ( "Extracting all files from archive..." );
923
		printf ( "Extracting all files from archive..." );
921
		if ( pBaseFile->ExtractAll ( dir, game ) )
924
		if (packages.extractAll(pBaseFile, dir, game) )
922
			printf ( "(Done)\nFiles have been extracted successfully\n" );
925
			printf ( "(Done)\nFiles have been extracted successfully\n" );
923
		else
926
		else
924
			printf ( "(Error)\nThere was a problem extracting the files\n" );
927
			printf ( "(Error)\nThere was a problem extracting the files\n" );
925
	}
928
	}
926
	else
929
	else
Line 1602... Line 1605...
1602
	{
1605
	{
1603
		if ( argc < 3 )
1606
		if ( argc < 3 )
1604
			printf ( "Syntax:\n\t%s -e <spkfile> [destination]\n\t--extractall <spkfile> <game> [destination]\n\t\tThis will extract all files of a set game into the destination directory\n\n\t\tGame = 0 will extract all files", cmd.c_str() );
1607
			printf ( "Syntax:\n\t%s -e <spkfile> [destination]\n\t--extractall <spkfile> <game> [destination]\n\t\tThis will extract all files of a set game into the destination directory\n\n\t\tGame = 0 will extract all files", cmd.c_str() );
1605
		else
1608
		else
1606
		{
1609
		{
1607
			CyString arg4;
1610
			Utils::String arg4;
1608
			if ( argc > 4 )
1611
			if ( argc > 4 )
1609
				arg4 = argv[4];
1612
				arg4 = argv[4];
1610
			ExtractFiles ( argv[2], arg4, atoi(argv[3]) );
1613
			ExtractFiles(argv[2], arg4, atoi(argv[3]) );
1611
		}
1614
		}
1612
	}
1615
	}
1613
 
1616
 
1614
	// creates a multispk archive
1617
	// creates a multispk archive
1615
	else if ( command == "-n" || command == "--createmulti" )
1618
	else if ( command == "-n" || command == "--createmulti" )