Subversion Repositories spk

Rev

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

Rev 176 Rev 177
Line 669... Line 669...
669
		{
669
		{
670
			printf ( "Error: Failed to open the Multi-SPK file, %s\n", filename.c_str() );
670
			printf ( "Error: Failed to open the Multi-SPK file, %s\n", filename.c_str() );
671
			return;
671
			return;
672
		}
672
		}
673
 
673
 
674
		printf ( "Multi Package Name: %s\n", spkfile.GetName().c_str() );
674
		printf ( "Multi Package Name: %s\n", spkfile.name().c_str() );
675
		printf ( "Selection Mode: " );
675
		printf ( "Selection Mode: " );
676
		if ( spkfile.IsSelection () )
676
		if (spkfile.isSelection ())
677
			printf ( "On\n" );
677
			printf ( "On\n" );
678
		else
678
		else
679
			printf ( "Off\n" );
679
			printf ( "Off\n" );
680
 
680
 
681
		CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
681
		CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
Line 800... Line 800...
800
	}
800
	}
801
	else if ( check == SPKFILE_MULTI )
801
	else if ( check == SPKFILE_MULTI )
802
	{
802
	{
803
		CMultiSpkFile spkfile;
803
		CMultiSpkFile spkfile;
804
		printf ( "Opening Multi-SPK file, %s...", sfile.c_str() );
804
		printf ( "Opening Multi-SPK file, %s...", sfile.c_str() );
805
		if ( !spkfile.ReadFile ( sfile ) )
805
		if ( !spkfile.readFile(sfile.ToString()))
806
		{
806
		{
807
			printf ( "(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str() );
807
			printf ( "(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str() );
808
			return;
808
			return;
809
		}
809
		}
810
		printf ( "(Done)\n" );
810
		printf ( "(Done)\n" );
811
 
811
 
812
		SMultiSpkFile *ms = spkfile.FindFile ( type );
812
		const SMultiSpkFile *ms = spkfile.findFile ( type.ToString() );
813
		if ( !ms )
813
		if ( !ms )
814
		{
814
		{
815
			printf ( "Unable to find the file \"%s\" in the package\n", type.c_str() );
815
			printf ( "Unable to find the file \"%s\" in the package\n", type.c_str() );
816
			return;
816
			return;
817
		}
817
		}
818
 
818
 
819
		printf ( "Removing file, %s, from Package\n", addfile.c_str() );
819
		printf ( "Removing file, %s, from Package\n", addfile.c_str() );
820
		if ( !spkfile.RemoveFile ( ms ) )
820
		if (!spkfile.removeFile(ms))
821
		{
821
		{
822
			printf ( "Error: Unable to remove file, %s, from package\n", type.c_str() );
822
			printf ( "Error: Unable to remove file, %s, from package\n", type.c_str() );
823
			return;
823
			return;
824
		}
824
		}
825
 
825
 
826
		printf ( "Writing SPK File, %s... ", sfile.c_str() );
826
		printf ( "Writing SPK File, %s... ", sfile.c_str() );
827
		if ( spkfile.WriteFile ( sfile ) )
827
		if (spkfile.writeFile(sfile.ToString()))
828
			printf ( "(Done)\n" );
828
			printf ( "(Done)\n" );
829
		else
829
		else
830
			printf ( "(Error)\n" );
830
			printf ( "(Error)\n" );
831
	}
831
	}
832
	else
832
	else
Line 857... Line 857...
857
 
857
 
858
	CMultiSpkFile spkfile;
858
	CMultiSpkFile spkfile;
859
 
859
 
860
	CyString sInput;
860
	CyString sInput;
861
	printf ( "Enter Multi-Spk Package Name: " );
861
	printf ( "Enter Multi-Spk Package Name: " );
862
	spkfile.SetName ( GetInput() );
862
	spkfile.setName(GetInput());
863
 
863
 
864
	while ( true )
864
	while ( true )
865
	{
865
	{
866
		printf ( "\nDo you want users to select scripts to install? (Y/N): " );
866
		printf ( "\nDo you want users to select scripts to install? (Y/N): " );
867
		CyString i = GetInput();
867
		CyString i = GetInput();
868
		i = i.ToUpper();
868
		i = i.ToUpper();
869
		if ( i == "Y" )
869
		if ( i == "Y" )
870
			spkfile.SetSelection ( true );
870
			spkfile.setSelection(true);
871
		if ( (i == "Y") || (i == "N") )
871
		if ( (i == "Y") || (i == "N") )
872
			break;
872
			break;
873
	}
873
	}
874
 
874
 
875
	while ( true )
875
	while ( true )
Line 884... Line 884...
884
		if ( !id2 )
884
		if ( !id2 )
885
			printf ( "Error: Unable to open SPK file %s\n", sInput.c_str() );
885
			printf ( "Error: Unable to open SPK file %s\n", sInput.c_str() );
886
		else
886
		else
887
		{
887
		{
888
			fclose ( id2 );
888
			fclose ( id2 );
889
			if ( !spkfile.AddFile ( sInput ) )
889
			if ( !spkfile.addFile(sInput.ToString()))
890
				printf ( "Error: Unable to add SPK file to package\n" );
890
				printf ( "Error: Unable to add SPK file to package\n" );
891
			else
891
			else
892
				printf ( "File Added to package (%s)\n", sInput.c_str() );
892
				printf ( "File Added to package (%s)\n", sInput.c_str() );
893
		}
893
		}
894
	}
894
	}
895
 
895
 
896
	if ( spkfile.GetNumFiles() < 1 )
896
	if ( spkfile.numFiles() < 1 )
897
		printf ( "\nError: You have added no files, you must add at least one file to create a package\n" );
897
		printf ( "\nError: You have added no files, you must add at least one file to create a package\n" );
898
	else
898
	else
899
	{
899
	{
900
		printf ( "Writing MultiSpk file... " );
900
		printf ( "Writing MultiSpk file... " );
901
		if ( spkfile.WriteFile ( filename ) )
901
		if ( spkfile.writeFile(filename.ToString()))
902
			printf ( "(Done)\n" );
902
			printf ( "(Done)\n" );
903
		else
903
		else
904
			printf ( "(Error)\n" );
904
			printf ( "(Error)\n" );
905
	}
905
	}
906
 
906
 
Line 1026... Line 1026...
1026
	// if the destination is a single file, then convert it to a Multi-Spk package
1026
	// if the destination is a single file, then convert it to a Multi-Spk package
1027
	if ( checkto == SPKFILE_SINGLE )
1027
	if ( checkto == SPKFILE_SINGLE )
1028
	{
1028
	{
1029
		// adds the single file to the Multi-Spk object
1029
		// adds the single file to the Multi-Spk object
1030
		// Add file also reads it into memory
1030
		// Add file also reads it into memory
1031
		if ( !spkfile.AddFile ( toFile ) )
1031
		if ( !spkfile.addFile(toFile.ToString()))
1032
		{
1032
		{
1033
			printf ( "Error: Unable to create Multi-Spk file\n" );
1033
			printf ( "Error: Unable to create Multi-Spk file\n" );
1034
			return;
1034
			return;
1035
		}
1035
		}
1036
	}
1036
	}
1037
	else
1037
	else
1038
	{
1038
	{
1039
		// if its already a multispk file, then simply open it and read it to memory
1039
		// if its already a multispk file, then simply open it and read it to memory
1040
		if ( !spkfile.ReadFile ( toFile ) )
1040
		if ( !spkfile.readFile(toFile.ToString()))
1041
		{
1041
		{
1042
			printf ( "Error: Unable to open Multi-Spk file, %s\n", toFile.c_str() );
1042
			printf ( "Error: Unable to open Multi-Spk file, %s\n", toFile.c_str() );
1043
			return;
1043
			return;
1044
		}
1044
		}
1045
	}
1045
	}
1046
 
1046
 
1047
	// now add the file into the Multi-Spk Object
1047
	// now add the file into the Multi-Spk Object
1048
	// the AddFile function will handle both single and Multi-Spk files
1048
	// the AddFile function will handle both single and Multi-Spk files
1049
	// So you dont need to test what the appending file is
1049
	// So you dont need to test what the appending file is
1050
	if ( spkfile.AddFile ( addfile ) )
1050
	if ( spkfile.addFile(addfile.ToString()))
1051
	{
1051
	{
1052
 
1052
 
1053
		// if it added correctly, then simply write the new Multi-Spk Object to disk
1053
		// if it added correctly, then simply write the new Multi-Spk Object to disk
1054
		printf ( "File, %s, has been added to Multi-Spk Package\n", addfile.c_str() );
1054
		printf ( "File, %s, has been added to Multi-Spk Package\n", addfile.c_str() );
1055
		printf ( "Saving Multi-Spk File: %s... ", toFile.c_str() );
1055
		printf ( "Saving Multi-Spk File: %s... ", toFile.c_str() );
1056
		if ( spkfile.WriteFile ( toFile ) )
1056
		if ( spkfile.writeFile(toFile.ToString()))
1057
			printf ( "(Done)\n" );
1057
			printf ( "(Done)\n" );
1058
		else
1058
		else
1059
			printf ( "(Error)\n" );
1059
			printf ( "(Error)\n" );
1060
	}
1060
	}
1061
	else
1061
	else
Line 1166... Line 1166...
1166
		// creates MultiSpkFile object
1166
		// creates MultiSpkFile object
1167
		CMultiSpkFile spkfile;
1167
		CMultiSpkFile spkfile;
1168
		printf ( "Opening Multi-SPK file, %s...", sfile.c_str() );
1168
		printf ( "Opening Multi-SPK file, %s...", sfile.c_str() );
1169
 
1169
 
1170
		// reads the MultiSpkFile into memory
1170
		// reads the MultiSpkFile into memory
1171
		if ( !spkfile.ReadFile ( sfile ) )
1171
		if ( !spkfile.readFile(sfile))
1172
		{
1172
		{
1173
			printf ( "(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str() );
1173
			printf ( "(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str() );
1174
			return;
1174
			return;
1175
		}
1175
		}
1176
		printf ( "(Done)\n" );
1176
		printf ( "(Done)\n" );
1177
 
1177
 
1178
		// searchs the archive for a matching file
1178
		// searchs the archive for a matching file
1179
		SMultiSpkFile *ms = spkfile.FindFile ( type );
1179
		const SMultiSpkFile *ms = spkfile.findFile(type);
1180
		if ( !ms )
1180
		if ( !ms )
1181
		{
1181
		{
1182
			printf ( "Unable to find the file \"%s\" in the package\n", type.c_str() );
1182
			printf ( "Unable to find the file \"%s\" in the package\n", type.c_str() );
1183
			return;
1183
			return;
1184
		}
1184
		}
1185
 
1185
 
1186
		// extracts the file from the archive, to the given directory
1186
		// extracts the file from the archive, to the given directory
1187
		printf ( "Extracting SPK file, %s, from package... ", ms->sName.c_str() );
1187
		printf ( "Extracting SPK file, %s, from package... ", ms->sName.c_str() );
1188
		if ( spkfile.ExtractFile ( ms, addfile ) )
1188
		if (spkfile.extractFile(ms, addfile))
1189
			printf ( "(Done)\n" );
1189
			printf ( "(Done)\n" );
1190
		else
1190
		else
1191
			printf ( "(Error)\n" );
1191
			printf ( "(Error)\n" );
1192
	}
1192
	}
1193
	else
1193
	else
Line 1213... Line 1213...
1213
 
1213
 
1214
	// create the MultiSpkFile object
1214
	// create the MultiSpkFile object
1215
	CMultiSpkFile spkfile;
1215
	CMultiSpkFile spkfile;
1216
 
1216
 
1217
	// Splits the files to the destination
1217
	// Splits the files to the destination
1218
	if ( !spkfile.SplitMulti  ( filename, dest ) )
1218
	if ( !spkfile.splitMulti(filename.ToString(), dest.ToString()))
1219
	{
1219
	{
1220
		printf ( "(Error)\nUnable to split Multi-SPK package, %s\n", filename.c_str() );
1220
		printf ( "(Error)\nUnable to split Multi-SPK package, %s\n", filename.c_str() );
1221
		return;
1221
		return;
1222
	}
1222
	}
1223
 
1223