Subversion Repositories spk

Rev

Rev 298 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 298 Rev 341
Line 7... Line 7...
7
#include <MultiSpkFile.h>
7
#include <MultiSpkFile.h>
8
#include "../../HiP/HiP.h"
8
#include "../../HiP/HiP.h"
9
#include <Logging/log.h>
9
#include <Logging/log.h>
10
 
10
 
11
#ifdef _DEBUG
11
#ifdef _DEBUG
12
#define CLEANUP fclose ( id ); if ( data ) delete data; if ( uncomprData ) delete uncomprData; if ( !removeFile.Empty() ) remove ( removeFile.c_str() ); char pause; printf ( "Press Enter to Close\n" ); scanf ( "%c", &pause );
12
#define CLEANUP fclose ( id ); if ( data ) delete data; if ( uncomprData ) delete uncomprData; if ( !removeFile.Empty() ) remove ( removeFile.c_str() ); char pause; wprintf(L"Press Enter to Close\n"); scanf ( "%c", &pause );
13
#else
13
#else
14
#define CLEANUP fclose ( id ); if ( data ) delete data; if ( uncomprData ) delete uncomprData; if ( !removeFile.Empty() ) remove ( removeFile.c_str() ); 
14
#define CLEANUP fclose ( id ); if ( data ) delete data; if ( uncomprData ) delete uncomprData; if ( !removeFile.Empty() ) remove ( removeFile.c_str() ); 
15
#endif
15
#endif
16
 
16
 
17
char *ReadNextLine ( char *data, long *len, Utils::String *str )
17
char *ReadNextLine ( char *data, long *len, Utils::String *str )
Line 65... Line 65...
65
	CConsoleLog::create();
65
	CConsoleLog::create();
66
 
66
 
67
	Utils::String filename ( argv[0] );
67
	Utils::String filename ( argv[0] );
68
	filename = filename.tokens("\\", -1, -1);
68
	filename = filename.tokens("\\", -1, -1);
69
 
69
 
70
	printf ( "SPKConvert V1.10 (SPK VERSION %.2f) 28/07/2007 by Cycrow\n", FILEVERSION );
70
	wprintf(L"SPKConvert V1.10 (SPK VERSION %.2f) 28/07/2007 by Cycrow\n", FILEVERSION );
71
 
71
 
72
	if ( argc < 3 )
72
	if ( argc < 3 )
73
	{
73
	{
74
		printf ( "Syntax, %s <oldspkfile> <newspkfile>\n", filename.c_str() );
74
		wprintf(L"Syntax, %hs <oldspkfile> <newspkfile>\n", filename.c_str() );
75
		exit ( 1 );
75
		exit ( 1 );
76
	}
76
	}
77
 
77
 
78
	Utils::String oldfile(argv[1]);
78
	Utils::String oldfile(argv[1]);
79
	Utils::String newfile(argv[2]);
79
	Utils::String newfile(argv[2]);
80
 
80
 
81
 
81
 
82
	int ret = CBaseFile::CheckFile ( oldfile );
82
	int ret = CBaseFile::CheckFile ( oldfile );
83
	if ( ret != SPKFILE_INVALID && ret != SPKFILE_OLD )
83
	if ( ret != SPKFILE_INVALID && ret != SPKFILE_OLD )
84
	{
84
	{
85
		printf ( "Spk file is already in the new format, unable to convert\n" );
85
		wprintf(L"Spk file is already in the new format, unable to convert\n" );
86
		exit ( 1 );
86
		exit ( 1 );
87
	}
87
	}
88
 
88
 
89
	// firstcheck if the file exists
89
	// firstcheck if the file exists
90
	FILE *id = fopen ( argv[1], "rb" );
90
	FILE *id = fopen ( argv[1], "rb" );
91
	if ( !id )
91
	if ( !id )
92
	{
92
	{
93
		printf ( "Unable to open file: %s\n", argv[1] );
93
		wprintf(L"Unable to open file: %hs\n", argv[1] );
94
		exit ( 0 );
94
		exit ( 0 );
95
	}
95
	}
96
 
96
 
97
	// convert the old file
97
	// convert the old file
98
	CSpkFile newspkfile;
98
	CSpkFile newspkfile;
99
	newspkfile.convertOld(oldfile);
99
	newspkfile.convertOld(oldfile);
100
 
100
 
101
	MyProgress *progress = new MyProgress ( 0 );
101
	MyProgress *progress = new MyProgress ( 0 );
102
 
102
 
103
	// now save the spk file
103
	// now save the spk file
104
	printf ( "\nStarting to write new spk file\n" );
104
	wprintf(L"\nStarting to write new spk file\n" );
105
 
105
 
106
	//TODO: add multispk support
106
	//TODO: add multispk support
107
	/*
107
	/*
108
	if ( mspk )
108
	if ( mspk )
109
	{
109
	{
110
		for ( SMultiSpkFile *it = mspk->GetFileList()->First(); it; it = mspk->GetFileList()->Next() )
110
		for ( SMultiSpkFile *it = mspk->GetFileList()->First(); it; it = mspk->GetFileList()->Next() )
111
		{
111
		{
112
			for ( C_File *f = it->pFile->GetFileList()->First(); f; f = it->pFile->GetFileList()->Next() )
112
			for ( C_File *f = it->pFile->GetFileList()->First(); f; f = it->pFile->GetFileList()->Next() )
113
			{
113
			{
114
				printf ( "* Compressing %s...\n\t>", f->GetNameDirectory(it->pFile).c_str() );
114
				wprintf(L"* Compressing %s...\n\t>", f->GetNameDirectory(it->pFile).c_str() );
115
				if ( f->CompressData ( spkfile->GetDataCompression(), progress ) )
115
				if ( f->CompressData ( spkfile->GetDataCompression(), progress ) )
116
				{
116
				{
117
					progress->PrintDone();
117
					progress->PrintDone();
118
					printf ( "< (Done)\n" );
118
					wprintf(L"< (Done)\n" );
119
				}
119
				}
120
				else
120
				else
121
				{
121
				{
122
					progress->Reset();
122
					progress->Reset();
123
					printf ( "< (Error)\n" );
123
					wprintf(L"< (Error)\n" );
124
				}
124
				}
125
			}
125
			}
126
 
126
 
127
			FILE *id = tmpfile();
127
			FILE *id = tmpfile();
128
			if ( id )
128
			if ( id )
Line 140... Line 140...
140
		{
140
		{
141
			wprintf(L"* Compressing %s...\n\t>", f->getNameDirectory(&newspkfile).c_str() );
141
			wprintf(L"* Compressing %s...\n\t>", f->getNameDirectory(&newspkfile).c_str() );
142
			if ( f->CompressData ( newspkfile.dataCompression(), progress ) )
142
			if ( f->CompressData ( newspkfile.dataCompression(), progress ) )
143
			{
143
			{
144
				progress->PrintDone();
144
				progress->PrintDone();
145
				printf ( "< (Done)\n" );
145
				wprintf(L"< (Done)\n" );
146
			}
146
			}
147
			else
147
			else
148
			{
148
			{
149
				progress->Reset();
149
				progress->Reset();
150
				printf ( "< (Error)\n" );
150
				wprintf(L"< (Error)\n" );
151
			}
151
			}
152
		}
152
		}
153
	//}
153
	//}
154
 
154
 
155
	printf ( "* Writing to %s... ", argv[2] );
155
	wprintf(L"* Writing to %hs... ", argv[2] );
156
	/*
156
	/*
157
	if ( mspk )
157
	if ( mspk )
158
	{
158
	{
159
		if ( mspk->WriteFile (Utils::WString(argv[2]) ) )
159
		if ( mspk->WriteFile (Utils::WString(argv[2]) ) )
160
			printf ( "(Done)\n" );
160
			wprintf(L"(Done)\n" );
161
		else
161
		else
162
			printf ( "(Error)\n" );
162
			wprintf(L"(Error)\n" );
163
	}
163
	}
164
	else
164
	else
165
	{*/
165
	{*/
166
		newspkfile.writeFile(Utils::WString::FromString(argv[2]));
166
		newspkfile.writeFile(Utils::WString::FromString(argv[2]));
167
		printf ( "(Done)\n" );
167
		wprintf(L"(Done)\n" );
168
	//}
168
	//}
169
 
169
 
170
	printf ( "SPK file has been converted successfully\n" );
170
	wprintf(L"SPK file has been converted successfully\n" );
171
//	CLEANUP
171
//	CLEANUP
172
 
172
 
173
	return 1;
173
	return 1;
174
}
174
}