Subversion Repositories spk

Rev

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

Rev 172 Rev 175
Line 151... Line 151...
151
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
151
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
152
		return;
152
		return;
153
	}
153
	}
154
	fclose ( id );
154
	fclose ( id );
155
 
155
 
156
	int check = CSpkFile::CheckFile ( filename );
156
	int check = CSpkFile::CheckFile(filename.ToString());
157
	if ( check == SPKFILE_SINGLE )
157
	if ( check == SPKFILE_SINGLE )
158
	{
158
	{
159
		CSpkFile spkfile;
159
		CSpkFile spkfile;
160
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
160
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
161
		if ( !spkfile.ReadFile ( filename, SPKREAD_ALL ) )
161
		if ( !spkfile.readFile(filename.ToString(), SPKREAD_ALL))
162
		{
162
		{
163
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
163
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
164
			return;
164
			return;
165
		}
165
		}
166
 
166
 
167
		// now do the settings
167
		// now do the settings
168
		if ( settings.Compare("author") )
168
		if ( settings.Compare("author") )
169
		{
169
		{
170
			spkfile.setAuthor(argv[4]);
170
			spkfile.setAuthor(argv[4]);
171
			printf( "Settings Author to: %s\n", spkfile.author().c_str());
171
			printf( "Settings Author to: %s\n", spkfile.author().c_str());
172
		}
172
		}
173
 
173
 
174
		spkfile.WriteFile ( filename );
174
		spkfile.writeFile(filename.ToString());
175
		printf ( "\nSPK file has been written sucessfully\n" );
175
		printf ( "\nSPK file has been written sucessfully\n" );
176
	}
176
	}
177
	else
177
	else
178
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
178
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
179
}
179
}
180
 
180
 
181
void SetRating ( CyString filename, int ease, int changing, int rec )
181
void SetRating ( CyString filename, int ease, int changing, int rec )
182
{
182
{
183
	if ( ease > 5 )
183
	if ( ease > 5 )
184
		ease = 5;
184
		ease = 5;
185
	if ( changing > 5 )
185
	if ( changing > 5 )
186
		changing = 5;
186
		changing = 5;
187
	if ( changing > 5 )
187
	if ( changing > 5 )
188
		changing = 5;
188
		changing = 5;
189
 
189
 
190
	FILE *id = fopen ( filename.c_str(), "rb+" );
190
	FILE *id = fopen ( filename.c_str(), "rb+" );
191
	if ( !id )
191
	if ( !id )
192
	{
192
	{
193
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
193
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
194
		return;
194
		return;
195
	}
195
	}
196
	fclose ( id );
196
	fclose ( id );
197
 
197
 
198
	int check = CSpkFile::CheckFile ( filename );
198
	int check = CSpkFile::CheckFile(filename.ToString());
199
	if ( check == SPKFILE_SINGLE )
199
	if ( check == SPKFILE_SINGLE )
200
	{
200
	{
201
		CSpkFile spkfile;
201
		CSpkFile spkfile;
202
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
202
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
203
		if ( !spkfile.ReadFile ( filename, SPKREAD_ALL ) )
203
		if ( !spkfile.readFile(filename.ToString(), SPKREAD_ALL))
204
		{
204
		{
205
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
205
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
206
			return;
206
			return;
207
		}
207
		}
208
 
208
 
Line 210... Line 210...
210
 
210
 
211
		printf ( "Assigning Ease Of Use:\t\t%d\nAssigning Game Changing:\t%d\nAssigning Recommended:\t\t%d\n", ease, changing, rec);
211
		printf ( "Assigning Ease Of Use:\t\t%d\nAssigning Game Changing:\t%d\nAssigning Recommended:\t\t%d\n", ease, changing, rec);
212
		spkfile.setEaseOfUse(ease);
212
		spkfile.setEaseOfUse(ease);
213
		spkfile.setGameChanging(changing);
213
		spkfile.setGameChanging(changing);
214
		spkfile.setRecommended(rec);
214
		spkfile.setRecommended(rec);
215
		spkfile.WriteFile ( filename );
215
		spkfile.writeFile(filename.ToString());
216
		printf ( "\nSPK file has been written sucessfully\n" );
216
		printf ( "\nSPK file has been written sucessfully\n" );
217
 
217
 
218
	}
218
	}
219
	else
219
	else
220
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
220
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
Line 246... Line 246...
246
	{
246
	{
247
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
247
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
248
		return;
248
		return;
249
	}
249
	}
250
	fclose ( id );
250
	fclose ( id );
251
 
251
 
252
	// check its not a new format already
252
	// check its not a new format already
253
	int check = CSpkFile::CheckFile ( filename );
253
	int check = CSpkFile::CheckFile(filename.ToString());
254
	if ( check == SPKFILE_INVALID && CFileIO(filename).isFileExtension("xsp") )
254
	if ( check == SPKFILE_INVALID && CFileIO(filename).isFileExtension("xsp") )
255
	{
255
	{
256
		printf ( "* Converting XSP File, %s... ", filename.c_str() );
256
		printf ( "* Converting XSP File, %s... ", filename.c_str() );
257
		CXspFile xspFile;
257
		CXspFile xspFile;
258
		if ( !xspFile.ConvertOld(filename.ToString()) )
258
		if ( !xspFile.ConvertOld(filename.ToString()) )
Line 274... Line 274...
274
			}
274
			}
275
		}
275
		}
276
 
276
 
277
		printf ( "* Writing XSP File, %s... ", tofile.c_str() );
277
		printf ( "* Writing XSP File, %s... ", tofile.c_str() );
278
		// now we need to save it
278
		// now we need to save it
279
		if ( !xspFile.WriteFile(tofile) )
279
		if ( !xspFile.writeFile(tofile.ToString()) )
280
			printf ( "[ERROR]\n\nFailed to write file to, %s\n", tofile.c_str() );
280
			printf ( "[ERROR]\n\nFailed to write file to, %s\n", tofile.c_str() );
281
		else
281
		else
282
			printf ( "[DONE]\n\nFile: %s, has been converted to, %s\n", filename.c_str(), tofile.c_str() );
282
			printf ( "[DONE]\n\nFile: %s, has been converted to, %s\n", filename.c_str(), tofile.c_str() );
283
	}
283
	}
284
	else
284
	else
Line 302... Line 302...
302
 
302
 
303
	Utils::CStringList *ships = pVfs->getTShipsEntries();
303
	Utils::CStringList *ships = pVfs->getTShipsEntries();
304
	if ( !ships )
304
	if ( !ships )
305
	{
305
	{
306
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
306
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
307
		delete pVfs;
307
		delete pVfs;
308
		return;
308
		return;
309
	}
309
	}
310
 
310
 
311
	// now get the ship line to extract
311
	// now get the ship line to extract
312
	Utils::String tShipsLine;
312
	Utils::String tShipsLine;
313
	if ( shipid.Empty() )
313
	if ( shipid.Empty() )
314
	{
314
	{
315
		// no ship id, lets get one
315
		// no ship id, lets get one
Line 379... Line 379...
379
		currDate = localtime( &now );
379
		currDate = localtime( &now );
380
		strftime(dateString, sizeof dateString, "%d/%m/%Y", currDate);
380
		strftime(dateString, sizeof dateString, "%d/%m/%Y", currDate);
381
		ship.setCreationDate(dateString);
381
		ship.setCreationDate(dateString);
382
 
382
 
383
		printf("\nWriting file: %s...\n", to.c_str());
383
		printf("\nWriting file: %s...\n", to.c_str());
384
		if ( ship.WriteFile(to) )
384
		if ( ship.writeFile(to.ToString()) )
385
			printf("Ship file has been created: %s\n", to.c_str());
385
			printf("Ship file has been created: %s\n", to.c_str());
386
		else
386
		else
387
			printf("Error: Unable to write ship file, %s\n", to.c_str());
387
			printf("Error: Unable to write ship file, %s\n", to.c_str());
388
	}
388
	}
389
	else
389
	else
Line 426... Line 426...
426
	int check = CSpkFile::CheckFile ( filename );
426
	int check = CSpkFile::CheckFile ( filename );
427
	if ( check == SPKFILE_BASE )
427
	if ( check == SPKFILE_BASE )
428
	{
428
	{
429
		pBaseFile = new CBaseFile();
429
		pBaseFile = new CBaseFile();
430
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
430
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
431
		if ( !pBaseFile->ReadFile ( filename, SPKREAD_NODATA ) )
431
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
432
		{
432
		{
433
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
433
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
434
			return;
434
			return;
435
		}
435
		}
436
		read = true;
436
		read = true;
437
	}
437
	}
438
	else if ( check == SPKFILE_SINGLE )
438
	else if ( check == SPKFILE_SINGLE )
439
	{
439
	{
440
		pBaseFile = (CBaseFile *)new CSpkFile();
440
		pBaseFile = (CBaseFile *)new CSpkFile();
441
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
441
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
442
		if ( !pBaseFile->ReadFile ( filename, SPKREAD_NODATA ) )
442
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
443
		{
443
		{
444
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
444
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
445
			return;
445
			return;
446
		}
446
		}
447
		read = true;
447
		read = true;
448
	}
448
	}
449
	else if ( check == SPKFILE_SINGLESHIP )
449
	else if ( check == SPKFILE_SINGLESHIP )
450
	{
450
	{
451
		pBaseFile = (CBaseFile *)new CXspFile();
451
		pBaseFile = (CBaseFile *)new CXspFile();
452
		printf ( "* Opening XSP File, %s...\n", filename.c_str() );
452
		printf ( "* Opening XSP File, %s...\n", filename.c_str() );
453
		if ( !pBaseFile->ReadFile ( filename, SPKREAD_NODATA ) )
453
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
454
		{
454
		{
455
			printf ( "Failed to open the xsp files, %s\n", filename.c_str() );
455
			printf ( "Failed to open the xsp files, %s\n", filename.c_str() );
456
			return;
456
			return;
457
		}
457
		}
458
		read = true;
458
		read = true;
Line 663... Line 663...
663
	}
663
	}
664
	else if ( check == SPKFILE_MULTI )
664
	else if ( check == SPKFILE_MULTI )
665
	{
665
	{
666
		CMultiSpkFile spkfile;
666
		CMultiSpkFile spkfile;
667
		printf ( "* Opening Multi-SPK file, %s...\n", filename.c_str() );
667
		printf ( "* Opening Multi-SPK file, %s...\n", filename.c_str() );
668
		if ( !pBaseFile->ReadFile ( filename, false ) )
668
		if ( !pBaseFile->readFile(filename, false))
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
 
Line 706... Line 706...
706
	{
706
	{
707
		printf ( "The file type \"%s\" is invalid\n", type.c_str() );
707
		printf ( "The file type \"%s\" is invalid\n", type.c_str() );
708
		return;
708
		return;
709
	}
709
	}
710
 
710
 
711
	int check = CSpkFile::CheckFile ( sfile );
711
	int check = CSpkFile::CheckFile(sfile.ToString());
712
	CBaseFile *pBaseFile = 0;
712
	CBaseFile *pBaseFile = 0;
713
	if ( check == SPKFILE_SINGLE )
713
	if ( check == SPKFILE_SINGLE )
714
		pBaseFile = new CSpkFile();
714
		pBaseFile = new CSpkFile();
715
	else if ( check == SPKFILE_SINGLESHIP )
715
	else if ( check == SPKFILE_SINGLESHIP )
716
		pBaseFile = new CXspFile();
716
		pBaseFile = new CXspFile();
Line 718... Line 718...
718
		pBaseFile = new CBaseFile();
718
		pBaseFile = new CBaseFile();
719
 
719
 
720
	if ( !pBaseFile )
720
	if ( !pBaseFile )
721
	{
721
	{
722
		printf ( "Error: Invalid file format, unable to open\n" );
722
		printf ( "Error: Invalid file format, unable to open\n" );
723
		return;
723
		return;
724
	}
724
	}
725
 
725
 
726
	printf ( "Opening File, %s... ", sfile.c_str() );
726
	printf ( "Opening File, %s... ", sfile.c_str() );
727
	if ( !pBaseFile->ReadFile ( sfile ) )
727
	if ( !pBaseFile->readFile(sfile.ToString()))
728
	{
728
	{
729
		printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
729
		printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
730
		return;
730
		return;
731
	}
731
	}
732
	printf ( "(Done)\n" );
732
	printf ( "(Done)\n" );
733
 
733
 
734
	MyProgress progress(0);
734
	MyProgress progress(0);
735
 
735
 
736
	printf ( "Adding file %s to package\n\t>", addfile.c_str() );
736
	printf ( "Adding file %s to package\n\t>", addfile.c_str() );
737
 
737
 
738
	if ( pBaseFile->appendFile(addfile.ToString(), t, 0, false, Utils::String::Null(), &progress))
738
	if ( pBaseFile->appendFile(addfile.ToString(), t, 0, false, Utils::String::Null(), &progress))
739
	{
739
	{
740
		progress.PrintDone();
740
		progress.PrintDone();
741
		printf ( "< (Done)\n" );
741
		printf ( "< (Done)\n" );
742
 
742
 
743
		pBaseFile->WriteFile ( sfile );
743
		pBaseFile->writeFile(sfile.ToString());
744
		printf ( "\nFile has been written sucessfully\n" );
744
		printf ( "\nFile has been written sucessfully\n" );
745
	}
745
	}
746
	else
746
	else
747
		printf ( "< (Error)\n" );
747
		printf ( "< (Error)\n" );
748
}
748
}
749
 
749
 
750
void RemoveFile ( CyString sfile, CyString type, CyString addfile )
750
void RemoveFile ( CyString sfile, CyString type, CyString addfile )
751
{
751
{
752
	FILE *id = fopen ( sfile.c_str(), "rb+" );
752
	FILE *id = fopen ( sfile.c_str(), "rb+" );
753
	if ( !id )
753
	if ( !id )
754
	{
754
	{
755
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
755
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
756
		return;
756
		return;
757
	}
757
	}
758
 
758
 
759
	if ( addfile.Empty() )
759
	if ( addfile.Empty() )
760
	{
760
	{
761
		printf ( "Error: Remove filename is invalid\n" );
761
		printf ( "Error: Remove filename is invalid\n" );
762
		return;
762
		return;
763
	}
763
	}
764
	FileType t = GetFileTypeFromString(type.ToString());
764
	FileType t = GetFileTypeFromString(type.ToString());
765
	if (t == FileType::FILETYPE_UNKNOWN)
765
	if (t == FileType::FILETYPE_UNKNOWN)
766
	{
766
	{
767
		printf ( "The file type \"%s\" is invalid\n", type.c_str() );
767
		printf ( "The file type \"%s\" is invalid\n", type.c_str() );
768
		return;
768
		return;
769
	}
769
	}
770
 
770
 
771
	int check = CSpkFile::CheckFile ( sfile );
771
	int check = CSpkFile::CheckFile(sfile.ToString());
772
	CBaseFile *pBaseFile = 0;
772
	CBaseFile *pBaseFile = 0;
773
	if ( check == SPKFILE_SINGLE )
773
	if ( check == SPKFILE_SINGLE )
774
		pBaseFile = new CSpkFile();
774
		pBaseFile = new CSpkFile();
775
	else if ( check == SPKFILE_SINGLESHIP )
775
	else if ( check == SPKFILE_SINGLESHIP )
776
		pBaseFile = new CXspFile();
776
		pBaseFile = new CXspFile();
Line 778... Line 778...
778
		pBaseFile = new CBaseFile();
778
		pBaseFile = new CBaseFile();
779
 
779
 
780
	if ( pBaseFile )
780
	if ( pBaseFile )
781
	{
781
	{
782
		printf ( "Opening File, %s... ", sfile.c_str() );
782
		printf ( "Opening File, %s... ", sfile.c_str() );
783
		if ( !pBaseFile->ReadFile ( sfile ) )
783
		if ( !pBaseFile->readFile(sfile.ToString()))
784
		{
784
		{
785
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
785
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
786
			return;
786
			return;
787
		}
787
		}
788
		printf ( "(Done)\n" );
788
		printf ( "(Done)\n" );
Line 790... Line 790...
790
		printf ( "Removing file, %s, from Package\n", addfile.c_str() );
790
		printf ( "Removing file, %s, from Package\n", addfile.c_str() );
791
 
791
 
792
		if(pBaseFile->removeFile(addfile.ToString(), t))
792
		if(pBaseFile->removeFile(addfile.ToString(), t))
793
		{
793
		{
794
			printf ( "File, %s, has been remove from package\n", addfile.c_str() );
794
			printf ( "File, %s, has been remove from package\n", addfile.c_str() );
795
			pBaseFile->WriteFile ( sfile );
795
			pBaseFile->writeFile(sfile.ToString());
796
			printf ( "File has been written to disk successfully\n" );
796
			printf ( "File has been written to disk successfully\n" );
797
		}
797
		}
798
		else
798
		else
799
			printf ( "Unable to remove the file, %s, from the package\n", addfile.c_str() );
799
			printf ( "Unable to remove the file, %s, from the package\n", addfile.c_str() );
800
	}
800
	}
Line 809... Line 809...
809
		}
809
		}
810
		printf ( "(Done)\n" );
810
		printf ( "(Done)\n" );
811
 
811
 
812
		SMultiSpkFile *ms = spkfile.FindFile ( type );
812
		SMultiSpkFile *ms = spkfile.FindFile ( type );
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;
Line 826... Line 826...
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 ) )
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
833
		printf ( "Error: Invalid file format, unable to open\n" );
833
		printf ( "Error: Invalid file format, unable to open\n" );
834
}
834
}
835
 
835
 
836
 
836
 
837
void CreateMultiFile ( CyString filename )
837
void CreateMultiFile ( CyString filename )
838
{
838
{
839
	printf ( "* Creating new Multi-SPK File, %s\n\n", filename.c_str() );
839
	printf ( "* Creating new Multi-SPK File, %s\n\n", filename.c_str() );
840
 
840
 
841
	FILE *id = fopen ( filename.c_str(), "rb+" );
841
	FILE *id = fopen ( filename.c_str(), "rb+" );
842
	if ( id )
842
	if ( id )
843
	{
843
	{
844
		fclose ( id );
844
		fclose ( id );
845
		printf ( "* File already exists, unable to create\n" );
845
		printf ( "* File already exists, unable to create\n" );
846
		return;
846
		return;
847
	}
847
	}
848
 
848
 
849
	id = fopen ( filename.c_str(), "wb" );
849
	id = fopen ( filename.c_str(), "wb" );
850
	if ( !id )
850
	if ( !id )
851
	{
851
	{
852
		printf ( "* Unable to open file for writing\n" );
852
		printf ( "* Unable to open file for writing\n" );
853
		return;
853
		return;
854
	}
854
	}
855
	fclose ( id );
855
	fclose ( id );
856
	remove ( filename.c_str() );
856
	remove ( filename.c_str() );
Line 897... Line 897...
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 ) )
902
			printf ( "(Done)\n" );
902
			printf ( "(Done)\n" );
903
		else
903
		else
904
			printf ( "(Error)\n" );
904
			printf ( "(Error)\n" );
905
	}
905
	}
906
 
906
 
907
}
907
}
908
 
908
 
909
void CreateFile ( CyString filename )
909
void CreateFile ( CyString filename )
910
{
910
{
Line 947... Line 947...
947
 
947
 
948
	currDate = localtime( &now );
948
	currDate = localtime( &now );
949
	strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
949
	strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
950
	spkfile.setCreationDate(dateString);
950
	spkfile.setCreationDate(dateString);
951
 
951
 
952
	spkfile.WriteFile ( filename, NULL );
952
	spkfile.writeFile(filename.ToString(), NULL);
953
	printf ( "SPK file has been written to disk: %s\n", filename.c_str() );
953
	printf ( "SPK file has been written to disk: %s\n", filename.c_str() );
954
}
954
}
955
 
955
 
956
void ExtractFiles (const Utils::String &sfile, const Utils::String &dir, int game )
956
void ExtractFiles (const Utils::String &sfile, const Utils::String &dir, int game )
957
{
957
{
Line 982... Line 982...
982
			pBaseFile = new CBaseFile();
982
			pBaseFile = new CBaseFile();
983
 
983
 
984
		printf ( "Opening File, %s... ", sfile.c_str() );
984
		printf ( "Opening File, %s... ", sfile.c_str() );
985
		// reads the file into memory
985
		// reads the file into memory
986
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
986
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
987
		if ( !pBaseFile->ReadFile ( sfile, SPKREAD_NODATA ) )
987
		if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
988
		{
988
		{
989
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
989
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
990
			return;
990
			return;
991
		}
991
		}
992
		printf ( "(Done)\n" );
992
		printf ( "(Done)\n" );
Line 1019... Line 1019...
1019
{
1019
{
1020
	// create destination object
1020
	// create destination object
1021
	CMultiSpkFile spkfile;
1021
	CMultiSpkFile spkfile;
1022
 
1022
 
1023
	// checks the destination
1023
	// checks the destination
1024
	int checkto = CSpkFile::CheckFile ( toFile );
1024
	int checkto = CSpkFile::CheckFile(toFile.ToString());
1025
 
1025
 
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
Line 1113... Line 1113...
1113
			pBaseFile = new CBaseFile();
1113
			pBaseFile = new CBaseFile();
1114
 
1114
 
1115
		printf ( "Opening File, %s... ", sfile.c_str() );
1115
		printf ( "Opening File, %s... ", sfile.c_str() );
1116
		// reads the file into memory
1116
		// reads the file into memory
1117
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
1117
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
1118
		if ( !pBaseFile->ReadFile ( sfile, SPKREAD_NODATA ) )
1118
		if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
1119
		{
1119
		{
1120
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
1120
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
1121
			return;
1121
			return;
1122
		}
1122
		}
1123
 
1123
 
Line 1149... Line 1149...
1149
		// if it uses 7zip, the progress will be displayed in the command prompt
1149
		// if it uses 7zip, the progress will be displayed in the command prompt
1150
		MyProgress progress(0);
1150
		MyProgress progress(0);
1151
		printf ( "Extracting the file from package\n\t>" );
1151
		printf ( "Extracting the file from package\n\t>" );
1152
 
1152
 
1153
		// Extracts the file to the specified directory
1153
		// Extracts the file to the specified directory
1154
		if ( !pBaseFile->ExtractFile ( f, dir, true, &progress ) )
1154
		if ( !pBaseFile->extractFile(f, dir, true, &progress))
1155
			printf ( "< (Error)\nUnable to extract the file\n" );
1155
			printf ( "< (Error)\nUnable to extract the file\n" );
1156
		else
1156
		else
1157
		{
1157
		{
1158
			progress.PrintDone ();
1158
			progress.PrintDone ();
1159
			printf ( "< (Done)\nFile has been extracted successfully\n" );
1159
			printf ( "< (Done)\nFile has been extracted successfully\n" );
Line 1201... Line 1201...
1201
	Desc:	Splits a multi-spk file into its seperate spk files
1201
	Desc:	Splits a multi-spk file into its seperate spk files
1202
*/
1202
*/
1203
void SplitMulti ( CyString filename, CyString dest )
1203
void SplitMulti ( CyString filename, CyString dest )
1204
{
1204
{
1205
	// Check the file type, Must return SPKFILE_MULTI, otherwise its not a Multi-Spk Packages
1205
	// Check the file type, Must return SPKFILE_MULTI, otherwise its not a Multi-Spk Packages
1206
	if ( CSpkFile::CheckFile ( filename ) != SPKFILE_MULTI )
1206
	if ( CSpkFile::CheckFile(filename.ToString()) != SPKFILE_MULTI )
1207
	{
1207
	{
1208
		printf ( "Error: The file is not a Multi-Spk packages\n" );
1208
		printf ( "Error: The file is not a Multi-Spk packages\n" );
1209
		return;
1209
		return;
1210
	}
1210
	}
1211
 
1211
 
Line 1345... Line 1345...
1345
	{
1345
	{
1346
		printf("Error: The package file, %s, does not exist", spkfile.c_str());
1346
		printf("Error: The package file, %s, does not exist", spkfile.c_str());
1347
		return;
1347
		return;
1348
	}
1348
	}
1349
 
1349
 
1350
	int check = CSpkFile::CheckFile(spkfile);
1350
	int check = CSpkFile::CheckFile(spkfile.ToString());
1351
	if ( check == SPKFILE_MULTI )
1351
	if ( check == SPKFILE_MULTI )
1352
	{
1352
	{
1353
		printf("Error: Multi-Package files currently not supported\n");
1353
		printf("Error: Multi-Package files currently not supported\n");
1354
		return;
1354
		return;
1355
	}
1355
	}
Line 1515... Line 1515...
1515
		if ( verify )
1515
		if ( verify )
1516
			printf("Package can be created from this script\n");
1516
			printf("Package can be created from this script\n");
1517
		else
1517
		else
1518
		{
1518
		{
1519
			// write script
1519
			// write script
1520
			if ( package->WriteFile(saveto) )
1520
			if ( package->writeFile(saveto) )
1521
			{
1521
			{
1522
				if ( package->AutoGenerateUpdateFile() )
1522
				if ( package->AutoGenerateUpdateFile() )
1523
					package->createUpdateFile(CFileIO(saveto).dir());
1523
					package->createUpdateFile(CFileIO(saveto).dir());
1524
				printf("Package: %s was created\n", saveto.c_str());
1524
				printf("Package: %s was created\n", saveto.c_str());
1525
			}
1525
			}
Line 1537... Line 1537...
1537
			if ( verify )
1537
			if ( verify )
1538
				printf("Package can be exported from this script\n");
1538
				printf("Package can be exported from this script\n");
1539
			else
1539
			else
1540
			{
1540
			{
1541
				// export
1541
				// export
1542
				if ( package->SaveToArchive(saveto, 0, p.GetGameExe()) ) {
1542
				if ( package->saveToArchive(saveto, 0, p.GetGameExe()) ) {
1543
					if ( package->IsAnyGameInPackage() ) {
1543
					if ( package->IsAnyGameInPackage() ) {
1544
						for ( int i = 0; i < p.GetGameExe()->GetNumGames(); i++ ) {
1544
						for ( int i = 0; i < p.GetGameExe()->GetNumGames(); i++ ) {
1545
							if ( package->IsGameInPackage(i + 1) ) {								
1545
							if ( package->IsGameInPackage(i + 1) ) {								
1546
								Utils::String exportFile = CFileIO(saveto).dir() + "/" + CFileIO(saveto).baseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(saveto).extension();
1546
								Utils::String exportFile = CFileIO(saveto).dir() + "/" + CFileIO(saveto).baseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(saveto).extension();
1547
								package->SaveToArchive(exportFile, i + 1, p.GetGameExe());
1547
								package->saveToArchive(exportFile, i + 1, p.GetGameExe());
1548
							}
1548
							}
1549
						}
1549
						}
1550
					}
1550
					}
1551
					printf("Package: %s was exported\n", saveto.c_str());
1551
					printf("Package: %s was exported\n", saveto.c_str());
1552
				}
1552
				}