| 1 |
cycrow |
1 |
/*
|
|
|
2 |
SPKTool V1.00 Created by Cycrow (Matthew Gravestock)
|
|
|
3 |
*/
|
|
|
4 |
|
|
|
5 |
// Main Spk File Library Include
|
|
|
6 |
#ifdef _WIN32
|
|
|
7 |
#include <spk.h>
|
|
|
8 |
#include <MultiSpkFile.h>
|
|
|
9 |
#include <spkcmdprogress.h>
|
|
|
10 |
#else
|
|
|
11 |
#include "../spk/spk.h"
|
|
|
12 |
#include "../spk/MultiSpkFile.h"
|
|
|
13 |
#include "../spk/spkcmdprogress.h"
|
|
|
14 |
#endif
|
|
|
15 |
// Multi Spk File format, required if using Multi Spk files
|
|
|
16 |
// Displays 7Zip compression progress to the command line
|
|
|
17 |
#include <time.h>
|
|
|
18 |
|
| 307 |
cycrow |
19 |
#include "Utils/CommandLine.h"
|
|
|
20 |
|
| 197 |
cycrow |
21 |
Utils::WString g_dir;
|
| 1 |
cycrow |
22 |
bool g_read;
|
|
|
23 |
|
| 134 |
cycrow |
24 |
class CFileProgress : public CProgressInfo
|
|
|
25 |
{
|
|
|
26 |
private:
|
| 298 |
cycrow |
27 |
Utils::WString _display;
|
| 134 |
cycrow |
28 |
CBaseFile *_package;
|
| 321 |
cycrow |
29 |
const CPackages *_packages;
|
| 134 |
cycrow |
30 |
|
|
|
31 |
public:
|
| 321 |
cycrow |
32 |
CFileProgress(const CPackages *packages, CBaseFile *package, const Utils::WString &display) :
|
| 134 |
cycrow |
33 |
_display(display),
|
|
|
34 |
_packages(packages),
|
|
|
35 |
_package(package)
|
|
|
36 |
{
|
|
|
37 |
|
|
|
38 |
}
|
|
|
39 |
|
| 311 |
cycrow |
40 |
void UpdateDisplay(const Utils::WString& display) override
|
|
|
41 |
{
|
|
|
42 |
wprintf(L"%s\n", display.c_str());
|
|
|
43 |
}
|
|
|
44 |
|
| 134 |
cycrow |
45 |
protected:
|
|
|
46 |
void ProgressUpdated(const long cur, const long max)
|
|
|
47 |
{
|
|
|
48 |
}
|
|
|
49 |
void DoingFile(C_File *file)
|
|
|
50 |
{
|
| 197 |
cycrow |
51 |
Utils::WString game;
|
| 134 |
cycrow |
52 |
|
|
|
53 |
if (!file->game() || file->game() == GAME_ALLNEW)
|
| 197 |
cycrow |
54 |
game = L"All Games";
|
| 134 |
cycrow |
55 |
else if (_packages)
|
|
|
56 |
{
|
|
|
57 |
for (unsigned int i = 0; i < 31; ++i)
|
|
|
58 |
{
|
|
|
59 |
if (file->game() & (1 << i))
|
|
|
60 |
{
|
| 321 |
cycrow |
61 |
Utils::WString g = _packages->gameExe()->gameNameFromType(i - 1);
|
| 134 |
cycrow |
62 |
if (!g.empty())
|
|
|
63 |
{
|
|
|
64 |
if (game.empty())
|
|
|
65 |
game = g;
|
|
|
66 |
else
|
| 197 |
cycrow |
67 |
game = game + L", " + g;
|
| 134 |
cycrow |
68 |
}
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
if(game.empty())
|
| 298 |
cycrow |
74 |
wprintf(L"%s: %s\n", _display.c_str(), file->getNameDirectory(_package).c_str());
|
| 134 |
cycrow |
75 |
else
|
| 298 |
cycrow |
76 |
wprintf(L"%s: %s [%s]\n", _display.c_str(), file->getNameDirectory(_package).c_str(), game.c_str());
|
| 134 |
cycrow |
77 |
}
|
|
|
78 |
|
|
|
79 |
};
|
|
|
80 |
|
| 1 |
cycrow |
81 |
/*
|
|
|
82 |
Func: GetInput
|
|
|
83 |
Desc: Gets an input from the user, ie, any settings required to be typed in
|
|
|
84 |
*/
|
| 197 |
cycrow |
85 |
Utils::WString GetInput ()
|
| 1 |
cycrow |
86 |
{
|
|
|
87 |
g_read = true;
|
|
|
88 |
|
| 298 |
cycrow |
89 |
Utils::WString line;
|
|
|
90 |
wchar_t c = getchar();
|
| 1 |
cycrow |
91 |
|
| 298 |
cycrow |
92 |
while ( (c != L'\n') && (c != L'\0') )
|
| 1 |
cycrow |
93 |
{
|
|
|
94 |
line += c;
|
|
|
95 |
c = getchar();
|
|
|
96 |
}
|
|
|
97 |
|
| 298 |
cycrow |
98 |
return line;
|
| 1 |
cycrow |
99 |
}
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
/*
|
|
|
103 |
Func: PrintSyntax
|
|
|
104 |
Args: String cmd - The command name to be displayed
|
|
|
105 |
Desc: Displays the syntax for the program
|
|
|
106 |
*/
|
| 298 |
cycrow |
107 |
void PrintSyntax(const Utils::WString &cmd)
|
| 1 |
cycrow |
108 |
{
|
| 298 |
cycrow |
109 |
wprintf(L"Syntax: %s <command>\n", cmd.c_str() );
|
|
|
110 |
wprintf(L"Commands:\n" );
|
| 307 |
cycrow |
111 |
wprintf(L"\t-v <spkfile>\n\t-view <spkfile>\n\t\tViews the contents of a spk file\n\n" );
|
|
|
112 |
wprintf(L"\t-e <spkfile> [destination]\n\t-extractall <spkfile> [destination]\n\t\tExtracts all the files to the destination directory [or current if no destiantion is set]\n\n" );
|
|
|
113 |
wprintf(L"\t-x <spkfile> <type> <file> [destination]\n\t-extract <spkfile> <type> <file> [destination]\n\t\tExtracts a single file of <type> to destination directory\n\n" );
|
|
|
114 |
wprintf(L"\t-x <multispkfile> <file> [destination]\n\t-extractspk <multispkfile> <spkfile> [destination]\n\t\tExtracts a single spk file from a Multi-Spk Package\n\n" );
|
|
|
115 |
wprintf(L"\t-c <spkfile>\n\t-create\n\t\tCreates a new spk file\n\n" );
|
|
|
116 |
wprintf(L"\t-a <spkfile> <type> <filename>\n\t-append <spkfile> <type> <filename>\n\t\tAppends a file to the package of set <type>\n\n" );
|
|
|
117 |
wprintf(L"\t-r <spkfile> <type> <filename>\n\t-remove <spkfile> <type> <filename>\n\t\tRemoves a file from the package of set <type>\n\n" );
|
|
|
118 |
wprintf(L"\t-r <multispkfile> <filename>\n\t-removespk <multispkfile> <filename>\n\t\tRemoves a spk file from the Multi-SPK package\n\n" );
|
|
|
119 |
wprintf(L"\t-m <spkfile> <spkfile>\n\t-mergemulti <spkfile> <spkfile>\n\t\tMerges spk files together, the second file will be merged into the first\n\n" );
|
|
|
120 |
wprintf(L"\t-n <multispkfile>\n\t-createmulti\n\t\tCreates a multi spk file, and adds the spkfiles in\n\n" );
|
|
|
121 |
wprintf(L"\t-s <multispkfile> [destination]\n\t-splitmulti <multispkfile> [destination]\n\t\tSplits a Multi-SPK file up, saves all the spk files to Destination\n\n" );
|
|
|
122 |
wprintf(L"\t-set <spkfile> <setting> [value]\n\t\tChanges the settings of the script\n\n" );
|
|
|
123 |
wprintf(L"\t-convertxsp <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
|
|
|
124 |
wprintf(L"\t-createscript <packagescript>\n\t\tCreates a spk file from a packager script\n\n");
|
|
|
125 |
wprintf(L"\t-verifyscript <packagescript>\n\t\tChecks a packager script is valid without creating the resulting file\n\n");
|
|
|
126 |
wprintf(L"\t-generatescript <package> [packagescript]\n\t\tCreates a packager script (.sps) from a spk file\n\n");
|
|
|
127 |
wprintf(L"\t-extractship <modfile> <xspfile> [shipid]\n\t\tCreates an XSP ship file from a mod package\n\n");
|
|
|
128 |
wprintf(L"\t-generateupdatefile <package>\n\t\tCreates an update file for the spk/xsp file\n\n");
|
|
|
129 |
wprintf(L"\t-packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n\n");
|
|
|
130 |
// printf ( "\t-convertxspwizard <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
|
| 1 |
cycrow |
131 |
}
|
|
|
132 |
|
| 307 |
cycrow |
133 |
void Settings(const Utils::CommandLine &cmd)
|
| 1 |
cycrow |
134 |
{
|
| 307 |
cycrow |
135 |
const Utils::WString &settings = cmd.arg(2);
|
|
|
136 |
const Utils::WString &filename = cmd.arg(1);
|
| 226 |
cycrow |
137 |
if ( settings.Compare(L"author") )
|
| 1 |
cycrow |
138 |
{
|
| 307 |
cycrow |
139 |
if (cmd.argCount() < 4)
|
| 1 |
cycrow |
140 |
{
|
| 307 |
cycrow |
141 |
wprintf(L"Syntax: %s -set <spkfile> Author <authorname>\n\tSets the authors name of the package\n", cmd.cmdName().c_str());
|
| 1 |
cycrow |
142 |
return;
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
else
|
|
|
146 |
{
|
| 226 |
cycrow |
147 |
wprintf(L"Error! Unknown settings: %s\n", settings.c_str());
|
| 1 |
cycrow |
148 |
return;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
// first chekc if file even exists
|
| 226 |
cycrow |
152 |
FILE *id = _wfopen(filename.c_str(), L"rb+");
|
| 1 |
cycrow |
153 |
if ( !id )
|
|
|
154 |
{
|
| 226 |
cycrow |
155 |
wprintf(L"Error: File, %s, doesn't exist\n", filename.c_str() );
|
| 1 |
cycrow |
156 |
return;
|
|
|
157 |
}
|
|
|
158 |
fclose ( id );
|
|
|
159 |
|
| 226 |
cycrow |
160 |
int check = CSpkFile::CheckFile(filename);
|
| 1 |
cycrow |
161 |
if ( check == SPKFILE_SINGLE )
|
|
|
162 |
{
|
|
|
163 |
CSpkFile spkfile;
|
| 226 |
cycrow |
164 |
wprintf(L"* Opening SPK File, %s...\n", filename.c_str());
|
|
|
165 |
if ( !spkfile.readFile(filename, SPKREAD_ALL))
|
| 1 |
cycrow |
166 |
{
|
| 226 |
cycrow |
167 |
wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
|
| 1 |
cycrow |
168 |
return;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
// now do the settings
|
| 226 |
cycrow |
172 |
if ( settings.Compare(L"author") )
|
| 1 |
cycrow |
173 |
{
|
| 307 |
cycrow |
174 |
spkfile.setAuthor(cmd.arg(3));
|
| 203 |
cycrow |
175 |
wprintf(L"Settings Author to: %s\n", spkfile.author().c_str());
|
| 1 |
cycrow |
176 |
}
|
|
|
177 |
|
| 226 |
cycrow |
178 |
spkfile.writeFile(filename);
|
| 1 |
cycrow |
179 |
printf ( "\nSPK file has been written sucessfully\n" );
|
|
|
180 |
}
|
|
|
181 |
else
|
| 226 |
cycrow |
182 |
wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
|
| 1 |
cycrow |
183 |
}
|
|
|
184 |
|
| 298 |
cycrow |
185 |
void SetRating (const Utils::WString &filename, int ease, int changing, int rec )
|
| 1 |
cycrow |
186 |
{
|
|
|
187 |
if ( ease > 5 )
|
|
|
188 |
ease = 5;
|
|
|
189 |
if ( changing > 5 )
|
|
|
190 |
changing = 5;
|
|
|
191 |
if ( changing > 5 )
|
|
|
192 |
changing = 5;
|
|
|
193 |
|
| 298 |
cycrow |
194 |
FILE *id = _wfopen(filename.c_str(), L"rb+");
|
| 1 |
cycrow |
195 |
if ( !id )
|
|
|
196 |
{
|
| 298 |
cycrow |
197 |
wprintf(L"Error: File, %s, doesn't exist\n", filename.c_str() );
|
| 1 |
cycrow |
198 |
return;
|
|
|
199 |
}
|
|
|
200 |
fclose ( id );
|
|
|
201 |
|
| 298 |
cycrow |
202 |
int check = CSpkFile::CheckFile(filename);
|
| 1 |
cycrow |
203 |
if ( check == SPKFILE_SINGLE )
|
|
|
204 |
{
|
|
|
205 |
CSpkFile spkfile;
|
| 298 |
cycrow |
206 |
wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
|
|
|
207 |
if ( !spkfile.readFile(filename, SPKREAD_ALL))
|
| 1 |
cycrow |
208 |
{
|
| 298 |
cycrow |
209 |
wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
|
| 1 |
cycrow |
210 |
return;
|
|
|
211 |
}
|
|
|
212 |
|
| 298 |
cycrow |
213 |
wprintf(L"File Format Version: %.2f\n", spkfile.fileVersion());
|
| 1 |
cycrow |
214 |
|
| 298 |
cycrow |
215 |
wprintf(L"Assigning Ease Of Use:\t\t%d\nAssigning Game Changing:\t%d\nAssigning Recommended:\t\t%d\n", ease, changing, rec);
|
| 46 |
cycrow |
216 |
spkfile.setEaseOfUse(ease);
|
|
|
217 |
spkfile.setGameChanging(changing);
|
|
|
218 |
spkfile.setRecommended(rec);
|
| 298 |
cycrow |
219 |
spkfile.writeFile(filename);
|
|
|
220 |
wprintf(L"\nSPK file has been written sucessfully\n" );
|
| 1 |
cycrow |
221 |
}
|
|
|
222 |
else
|
| 298 |
cycrow |
223 |
wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
|
| 1 |
cycrow |
224 |
}
|
|
|
225 |
|
| 197 |
cycrow |
226 |
Utils::WString GetTerranConflictDir()
|
| 1 |
cycrow |
227 |
{
|
|
|
228 |
while ( true )
|
|
|
229 |
{
|
|
|
230 |
printf ( "\nPlease enter the directory for terran conflict: ");
|
| 197 |
cycrow |
231 |
Utils::WString dir = GetInput();
|
| 185 |
cycrow |
232 |
if ( dir.empty() )
|
| 197 |
cycrow |
233 |
return Utils::WString::Null();
|
| 1 |
cycrow |
234 |
|
|
|
235 |
// check if the directory exists
|
| 197 |
cycrow |
236 |
if ( CFileIO::Exists(dir + L"/x3tc.exe") )
|
| 1 |
cycrow |
237 |
return dir;
|
| 197 |
cycrow |
238 |
wprintf(L"\nTerran Conflict installation doesn't exist: %s\n\n", dir.c_str());
|
| 1 |
cycrow |
239 |
}
|
|
|
240 |
|
| 197 |
cycrow |
241 |
return Utils::WString::Null();
|
| 1 |
cycrow |
242 |
}
|
|
|
243 |
|
| 298 |
cycrow |
244 |
void ConvertXsp(const Utils::WString &filename, const Utils::WString &tofile, bool wizard)
|
| 1 |
cycrow |
245 |
{
|
|
|
246 |
// first chekc if file even exists
|
| 218 |
cycrow |
247 |
FILE *id = _wfopen (filename.c_str(), L"rb+" );
|
| 1 |
cycrow |
248 |
if ( !id )
|
|
|
249 |
{
|
| 218 |
cycrow |
250 |
wprintf(L"Error: File, %s, doesn't exist\n", filename.c_str() );
|
| 1 |
cycrow |
251 |
return;
|
|
|
252 |
}
|
|
|
253 |
fclose ( id );
|
|
|
254 |
|
|
|
255 |
// check its not a new format already
|
| 185 |
cycrow |
256 |
int check = CSpkFile::CheckFile(filename);
|
| 196 |
cycrow |
257 |
if ( check == SPKFILE_INVALID && CFileIO(filename).isFileExtension(L"xsp") )
|
| 1 |
cycrow |
258 |
{
|
| 218 |
cycrow |
259 |
wprintf(L"* Converting XSP File, %s... ", filename.c_str() );
|
| 1 |
cycrow |
260 |
CXspFile xspFile;
|
| 218 |
cycrow |
261 |
if ( !xspFile.convertOld(filename) )
|
| 1 |
cycrow |
262 |
{
|
| 218 |
cycrow |
263 |
wprintf(L"[ERROR]\n\nFailed to convert old xsp file, %s\n", filename.c_str() );
|
| 1 |
cycrow |
264 |
return;
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
printf ( "[DONE]\n");
|
|
|
268 |
|
| 197 |
cycrow |
269 |
Utils::WString dir;
|
| 1 |
cycrow |
270 |
printf ("Do you want to create weapon masks for Terran conflict? ");
|
| 197 |
cycrow |
271 |
Utils::WString input = GetInput();
|
|
|
272 |
if ( input.Compare(L"y") || input.Compare(L"yes") )
|
| 1 |
cycrow |
273 |
{
|
|
|
274 |
dir = GetTerranConflictDir();
|
| 197 |
cycrow |
275 |
if (!dir.empty())
|
| 1 |
cycrow |
276 |
{
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
|
| 298 |
cycrow |
280 |
wprintf(L"* Writing XSP File, %s... ", tofile.c_str());
|
| 1 |
cycrow |
281 |
// now we need to save it
|
| 185 |
cycrow |
282 |
if ( !xspFile.writeFile(tofile) )
|
| 298 |
cycrow |
283 |
wprintf(L"[ERROR]\n\nFailed to write file to, %s\n", tofile.c_str() );
|
| 1 |
cycrow |
284 |
else
|
| 298 |
cycrow |
285 |
wprintf(L"[DONE]\n\nFile: %s, has been converted to, %s\n", filename.c_str(), tofile.c_str() );
|
| 1 |
cycrow |
286 |
}
|
|
|
287 |
else
|
| 218 |
cycrow |
288 |
wprintf(L"Error: File, %s, is not an old style XSP file\n", filename.c_str() );
|
| 1 |
cycrow |
289 |
}
|
|
|
290 |
|
| 298 |
cycrow |
291 |
void ExtractShip(const Utils::WString &catfile, const Utils::WString &to, Utils::WString shipid)
|
| 1 |
cycrow |
292 |
{
|
| 185 |
cycrow |
293 |
if ( !CFileIO::Exists(catfile) )
|
| 1 |
cycrow |
294 |
{
|
| 298 |
cycrow |
295 |
wprintf(L"Error: Mod File, %s, does not exist\n", catfile.c_str());
|
| 1 |
cycrow |
296 |
return;
|
|
|
297 |
}
|
|
|
298 |
|
| 36 |
cycrow |
299 |
CVirtualFileSystem *pVfs = new CVirtualFileSystem();
|
| 185 |
cycrow |
300 |
if ( !pVfs->loadMod(catfile) ) {
|
| 298 |
cycrow |
301 |
wprintf(L"Error: Unable to read mod file, %s\n", catfile.c_str());
|
| 36 |
cycrow |
302 |
delete pVfs;
|
| 1 |
cycrow |
303 |
return;
|
|
|
304 |
}
|
|
|
305 |
|
| 197 |
cycrow |
306 |
Utils::WStringList *ships = pVfs->getTShipsEntries();
|
| 1 |
cycrow |
307 |
if ( !ships )
|
|
|
308 |
{
|
| 298 |
cycrow |
309 |
wprintf(L"Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
|
| 36 |
cycrow |
310 |
delete pVfs;
|
| 1 |
cycrow |
311 |
return;
|
|
|
312 |
}
|
|
|
313 |
|
|
|
314 |
// now get the ship line to extract
|
| 197 |
cycrow |
315 |
Utils::WString tShipsLine;
|
| 185 |
cycrow |
316 |
if (shipid.empty())
|
| 1 |
cycrow |
317 |
{
|
|
|
318 |
// no ship id, lets get one
|
| 197 |
cycrow |
319 |
Utils::WString ids[2];
|
| 1 |
cycrow |
320 |
int i = 0;
|
|
|
321 |
int id = 0;
|
| 197 |
cycrow |
322 |
for ( Utils::WStringNode *str = ships->first(); str; str = ships->next() )
|
| 1 |
cycrow |
323 |
{
|
| 116 |
cycrow |
324 |
ids[i++] = str->data;
|
| 1 |
cycrow |
325 |
if ( i >= 2 )
|
|
|
326 |
{
|
| 197 |
cycrow |
327 |
wprintf(L"[%3d][%30s]\t[%3d][%30s]\n", id - 1, ids[0].c_str(), id, ids[1].c_str());
|
| 1 |
cycrow |
328 |
for ( i = 0; i < 2; i++ )
|
| 197 |
cycrow |
329 |
ids[i] = L"";
|
| 1 |
cycrow |
330 |
i = 0;
|
|
|
331 |
}
|
|
|
332 |
++id;
|
|
|
333 |
}
|
|
|
334 |
if ( i == 1 )
|
| 197 |
cycrow |
335 |
wprintf(L"[%3d][%30s]\n", id, ids[0].c_str());
|
| 1 |
cycrow |
336 |
printf("Enter ID to use > ");
|
|
|
337 |
shipid = GetInput();
|
|
|
338 |
|
| 185 |
cycrow |
339 |
if ( shipid.isNumber() )
|
|
|
340 |
tShipsLine = ships->get(shipid.toInt())->str;
|
| 1 |
cycrow |
341 |
else
|
| 185 |
cycrow |
342 |
tShipsLine = ships->findData(shipid, true);
|
| 1 |
cycrow |
343 |
}
|
|
|
344 |
else
|
| 185 |
cycrow |
345 |
ships->findData(shipid, true);
|
| 1 |
cycrow |
346 |
|
| 101 |
cycrow |
347 |
if ( tShipsLine.empty() )
|
| 1 |
cycrow |
348 |
{
|
| 197 |
cycrow |
349 |
wprintf(L"Error, %s is not a valid ship id to use\n", shipid.c_str());
|
| 36 |
cycrow |
350 |
delete pVfs;
|
| 1 |
cycrow |
351 |
return;
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
// now we have the tships to use, lets start to extract the ship
|
| 298 |
cycrow |
355 |
wprintf(L"Extracting ship from %s, Ship=%s\n", catfile.c_str(), tShipsLine.token(L";", -2).c_str());
|
| 1 |
cycrow |
356 |
|
|
|
357 |
CXspFile ship;
|
| 197 |
cycrow |
358 |
if ( ship.extractShip(pVfs, tShipsLine.token(L";", -2).toString(), 0))
|
| 1 |
cycrow |
359 |
{
|
|
|
360 |
printf ( "Ship has been successfully extracted\n" );
|
|
|
361 |
|
| 306 |
cycrow |
362 |
wprintf(L"\t- Models:\t %lu\n", static_cast<unsigned long>(ship.countFiles(FILETYPE_SHIPMODEL)));
|
|
|
363 |
wprintf(L"\t- Textures:\t %lu\n", static_cast<unsigned long>(ship.countFiles(FILETYPE_SHIPOTHER)));
|
| 1 |
cycrow |
364 |
printf("\t- Dummies:\t %d\n", ship.GetDummies()->size());
|
|
|
365 |
printf("\t- Components:\t %d\n", ship.GetComponents()->size());
|
| 306 |
cycrow |
366 |
wprintf(L"\t- Bodies:\t %lu\n", static_cast<unsigned long>(ship.getBodies().size()));
|
| 1 |
cycrow |
367 |
printf("\t- Cockpits:\t %d\n", ship.GetCockpits()->size());
|
|
|
368 |
printf("\t- Text Entries:\t %d\n", ship.GetTexts()->size());
|
|
|
369 |
|
|
|
370 |
printf("\nEnter the name for the ship: ");
|
| 197 |
cycrow |
371 |
ship.setName(GetInput().toString());
|
| 1 |
cycrow |
372 |
printf("Enter the author for the ship: ");
|
| 197 |
cycrow |
373 |
ship.setAuthor(GetInput().toString());
|
| 1 |
cycrow |
374 |
printf("Enter the version for the ship: V");
|
| 197 |
cycrow |
375 |
ship.setVersion(GetInput().toString());
|
| 1 |
cycrow |
376 |
printf("Enter the description for the ship: ");
|
| 197 |
cycrow |
377 |
ship.setDescription(GetInput().toString());
|
| 1 |
cycrow |
378 |
|
|
|
379 |
struct tm *currDate;
|
|
|
380 |
char dateString[100];
|
|
|
381 |
time_t now = time(NULL);
|
|
|
382 |
currDate = localtime( &now );
|
|
|
383 |
strftime(dateString, sizeof dateString, "%d/%m/%Y", currDate);
|
| 226 |
cycrow |
384 |
ship.setCreationDate(Utils::WString::FromString(dateString));
|
| 1 |
cycrow |
385 |
|
| 298 |
cycrow |
386 |
wprintf(L"\nWriting file: %s...\n", to.c_str());
|
| 185 |
cycrow |
387 |
if ( ship.writeFile(to) )
|
| 298 |
cycrow |
388 |
wprintf(L"Ship file has been created: %s\n", to.c_str());
|
| 1 |
cycrow |
389 |
else
|
| 298 |
cycrow |
390 |
wprintf(L"Error: Unable to write ship file, %s\n", to.c_str());
|
| 1 |
cycrow |
391 |
}
|
|
|
392 |
else
|
| 298 |
cycrow |
393 |
wprintf(L"Error: Unable to extract the ship\n");
|
| 36 |
cycrow |
394 |
|
|
|
395 |
delete pVfs;
|
| 1 |
cycrow |
396 |
}
|
|
|
397 |
|
| 298 |
cycrow |
398 |
Utils::WString GetGameName(int game)
|
| 1 |
cycrow |
399 |
{
|
|
|
400 |
switch(game)
|
|
|
401 |
{
|
|
|
402 |
case GAME_X2:
|
| 298 |
cycrow |
403 |
return L"X2: The Threat";
|
| 1 |
cycrow |
404 |
case GAME_X3:
|
| 298 |
cycrow |
405 |
return L"X3: Reunion";
|
| 1 |
cycrow |
406 |
case GAME_X3TC:
|
| 298 |
cycrow |
407 |
return L"X3: Terran Conflict";
|
| 1 |
cycrow |
408 |
case GAME_X3AP:
|
| 298 |
cycrow |
409 |
return L"X3: Albion Prelude";
|
| 126 |
cycrow |
410 |
case GAME_X3FL:
|
| 298 |
cycrow |
411 |
return L"X3: Farnham's Legacy";
|
| 1 |
cycrow |
412 |
}
|
| 298 |
cycrow |
413 |
return L"Unknown";
|
| 1 |
cycrow |
414 |
}
|
| 321 |
cycrow |
415 |
void DisplayVersion(const Utils::CommandLine &cmd)
|
| 1 |
cycrow |
416 |
{
|
| 321 |
cycrow |
417 |
const Utils::WString& filename = cmd.arg(1);
|
|
|
418 |
|
| 1 |
cycrow |
419 |
// first chekc if file even exists
|
| 298 |
cycrow |
420 |
FILE *id = _wfopen(filename.c_str(), L"rb+");
|
| 1 |
cycrow |
421 |
if ( !id )
|
|
|
422 |
{
|
| 298 |
cycrow |
423 |
wprintf(L"Error: File, %s, doesn't exist\n", filename.c_str());
|
| 1 |
cycrow |
424 |
return;
|
|
|
425 |
}
|
|
|
426 |
fclose ( id );
|
|
|
427 |
|
|
|
428 |
bool read = false;
|
|
|
429 |
CBaseFile *pBaseFile = NULL;
|
|
|
430 |
|
|
|
431 |
int check = CSpkFile::CheckFile ( filename );
|
|
|
432 |
if ( check == SPKFILE_BASE )
|
|
|
433 |
{
|
|
|
434 |
pBaseFile = new CBaseFile();
|
| 298 |
cycrow |
435 |
wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
|
| 175 |
cycrow |
436 |
if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
|
| 1 |
cycrow |
437 |
{
|
| 298 |
cycrow |
438 |
wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
|
| 1 |
cycrow |
439 |
return;
|
|
|
440 |
}
|
|
|
441 |
read = true;
|
|
|
442 |
}
|
|
|
443 |
else if ( check == SPKFILE_SINGLE )
|
|
|
444 |
{
|
|
|
445 |
pBaseFile = (CBaseFile *)new CSpkFile();
|
| 298 |
cycrow |
446 |
wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
|
| 175 |
cycrow |
447 |
if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
|
| 1 |
cycrow |
448 |
{
|
| 298 |
cycrow |
449 |
wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
|
| 1 |
cycrow |
450 |
return;
|
|
|
451 |
}
|
|
|
452 |
read = true;
|
|
|
453 |
}
|
|
|
454 |
else if ( check == SPKFILE_SINGLESHIP )
|
|
|
455 |
{
|
|
|
456 |
pBaseFile = (CBaseFile *)new CXspFile();
|
| 298 |
cycrow |
457 |
wprintf(L"* Opening XSP File, %s...\n", filename.c_str() );
|
| 175 |
cycrow |
458 |
if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
|
| 1 |
cycrow |
459 |
{
|
| 298 |
cycrow |
460 |
wprintf(L"Failed to open the xsp files, %s\n", filename.c_str() );
|
| 1 |
cycrow |
461 |
return;
|
|
|
462 |
}
|
|
|
463 |
read = true;
|
|
|
464 |
}
|
|
|
465 |
// otherwise its an old ship file
|
| 196 |
cycrow |
466 |
else if ( CFileIO(filename).isFileExtension(L"xsp") )
|
| 1 |
cycrow |
467 |
{
|
| 298 |
cycrow |
468 |
wprintf(L"* Converting XSP File, %s...\n", filename.c_str() );
|
| 1 |
cycrow |
469 |
pBaseFile = new CXspFile;
|
| 218 |
cycrow |
470 |
if ( !((CXspFile *)pBaseFile)->convertOld(filename) )
|
| 1 |
cycrow |
471 |
{
|
|
|
472 |
delete pBaseFile;
|
|
|
473 |
pBaseFile = NULL;
|
| 298 |
cycrow |
474 |
wprintf(L"Failed to convert old xsp file, %s\n", filename.c_str() );
|
| 1 |
cycrow |
475 |
return;
|
|
|
476 |
}
|
|
|
477 |
check = SPKFILE_SINGLESHIP;
|
|
|
478 |
read = true;
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
if ( pBaseFile && read)
|
|
|
482 |
{
|
|
|
483 |
CSpkFile *pSpkFile = NULL;
|
|
|
484 |
CXspFile *pXspFile = NULL;
|
|
|
485 |
if ( check == SPKFILE_SINGLE )
|
|
|
486 |
pSpkFile = (CSpkFile *)pBaseFile;
|
|
|
487 |
else
|
|
|
488 |
pXspFile = (CXspFile *)pBaseFile;
|
|
|
489 |
|
| 298 |
cycrow |
490 |
wprintf(L"File Format Version: %.2f\n", pBaseFile->fileVersion());
|
| 1 |
cycrow |
491 |
|
| 226 |
cycrow |
492 |
Utils::WString sType;
|
| 1 |
cycrow |
493 |
if ( check == SPKFILE_SINGLESHIP )
|
| 226 |
cycrow |
494 |
sType = L"Ship";
|
| 1 |
cycrow |
495 |
else
|
| 226 |
cycrow |
496 |
sType = L"Package";
|
| 1 |
cycrow |
497 |
|
| 226 |
cycrow |
498 |
wprintf(L"%s Name: %s\n", sType.c_str(), pBaseFile->name().c_str() );
|
| 49 |
cycrow |
499 |
if ( !pBaseFile->email().empty() )
|
| 226 |
cycrow |
500 |
wprintf(L"%s Author: %s (%s)\n", sType.c_str(), pBaseFile->author().c_str(), pBaseFile->email().c_str() );
|
| 1 |
cycrow |
501 |
else
|
| 226 |
cycrow |
502 |
wprintf(L"%s Author: %s\n", sType.c_str(), pBaseFile->author().c_str() );
|
|
|
503 |
if ( !pBaseFile->version().empty() ) wprintf(L"%s Version: %s\n", sType.c_str(), pBaseFile->version().c_str() );
|
| 1 |
cycrow |
504 |
|
|
|
505 |
//for game
|
|
|
506 |
printf("For Games: ");
|
|
|
507 |
if ( !pBaseFile->AnyGameCompatability() )
|
|
|
508 |
printf("All");
|
|
|
509 |
else
|
| 321 |
cycrow |
510 |
wprintf(L"%s", cmd.packages().getGameTypesString(pBaseFile, true).c_str());
|
| 1 |
cycrow |
511 |
printf("\n");
|
|
|
512 |
|
|
|
513 |
if ( pXspFile )
|
|
|
514 |
{
|
| 203 |
cycrow |
515 |
wprintf(L"Ship Display Name: %s\n", pXspFile->shipName(44).c_str());
|
| 1 |
cycrow |
516 |
if ( pXspFile->IsExistingShip() )
|
| 217 |
cycrow |
517 |
wprintf(L"Ship ID: %s (Replace Existing Ship)\n", pXspFile->shipID().c_str() );
|
| 1 |
cycrow |
518 |
else
|
| 217 |
cycrow |
519 |
wprintf(L"Ship ID: %s\n", pXspFile->shipID().c_str() );
|
| 1 |
cycrow |
520 |
|
| 244 |
cycrow |
521 |
if ( pXspFile->anyShipyards() )
|
| 1 |
cycrow |
522 |
{
|
|
|
523 |
printf ( "Add To Shipyards:\n" );
|
| 244 |
cycrow |
524 |
for (unsigned long i = 1; i <= GetMaxShipyards(); i *= 2 )
|
| 1 |
cycrow |
525 |
{
|
| 244 |
cycrow |
526 |
if ( pXspFile->isShipyard(static_cast<ShipyardRace>(i)) )
|
|
|
527 |
wprintf(L"\t%s\n", GetShipyardName(static_cast<ShipyardRace>(i)).c_str());
|
| 1 |
cycrow |
528 |
}
|
|
|
529 |
}
|
|
|
530 |
|
|
|
531 |
for ( SWeaponMask *text = pXspFile->GetLaserMasks()->First(); text; text = pXspFile->GetLaserMasks()->Next() )
|
| 298 |
cycrow |
532 |
wprintf(L"Laser Mask, Game: %s, Mask: %d\n", GetGameName(text->iGame).c_str(), text->iMask);
|
| 1 |
cycrow |
533 |
for ( SWeaponMask *text = pXspFile->GetMissileMasks()->First(); text; text = pXspFile->GetMissileMasks()->Next() )
|
| 298 |
cycrow |
534 |
wprintf(L"Missile Mask, Game: %s, Mask: %d\n", GetGameName(text->iGame).c_str(), text->iMask);
|
| 1 |
cycrow |
535 |
|
|
|
536 |
if ( pXspFile->GetOriginalDescription() )
|
| 298 |
cycrow |
537 |
wprintf(L"Use Existing Text, ID: %d\n", pXspFile->GetOriginalDescription());
|
| 1 |
cycrow |
538 |
|
|
|
539 |
if ( pXspFile->AnyTexts() )
|
|
|
540 |
{
|
|
|
541 |
for ( SText *text = pXspFile->GetTexts()->First(); text; text = pXspFile->GetTexts()->Next() )
|
|
|
542 |
{
|
| 298 |
cycrow |
543 |
wprintf(L"Ship Text, Language: %d\n", text->iId);
|
| 39 |
cycrow |
544 |
if ( !text->sName.empty() )
|
| 216 |
cycrow |
545 |
wprintf(L"\tName: %s\n", text->sName.c_str());
|
| 39 |
cycrow |
546 |
if ( !text->sDesc.empty() )
|
| 216 |
cycrow |
547 |
wprintf(L"\tDescription: %s\n", text->sDesc.c_str());
|
| 1 |
cycrow |
548 |
}
|
|
|
549 |
}
|
|
|
550 |
|
|
|
551 |
if ( pXspFile->AnyComponents() )
|
|
|
552 |
{
|
| 298 |
cycrow |
553 |
wprintf(L"Component Entries:\n" );
|
| 1 |
cycrow |
554 |
for ( SComponent *c = pXspFile->GetComponents()->First(); c; c = pXspFile->GetComponents()->Next() )
|
| 216 |
cycrow |
555 |
wprintf(L"\t%s\n\t\t%s\n\t\t\t%s\n", c->sSection.c_str(), c->sSection2.c_str(), c->sData.c_str());
|
| 1 |
cycrow |
556 |
}
|
|
|
557 |
if ( pXspFile->AnyDummies() )
|
|
|
558 |
{
|
| 298 |
cycrow |
559 |
wprintf(L"Dummy Entries:\n" );
|
| 1 |
cycrow |
560 |
for ( SDummy *d = pXspFile->GetDummies()->First(); d; d = pXspFile->GetDummies()->Next() )
|
| 216 |
cycrow |
561 |
wprintf(L"\t%s\n\t\t%s\n", d->sSection.c_str(), d->sData.c_str());
|
| 1 |
cycrow |
562 |
}
|
|
|
563 |
if ( pXspFile->AnyCockpits() )
|
|
|
564 |
{
|
| 298 |
cycrow |
565 |
wprintf(L"Cockpit Entries:\n" );
|
| 1 |
cycrow |
566 |
for ( SCockpit *c = pXspFile->GetCockpits()->First(); c; c = pXspFile->GetCockpits()->Next() )
|
| 216 |
cycrow |
567 |
wprintf(L"\t%s\n", c->sCockpit.c_str());
|
| 1 |
cycrow |
568 |
}
|
| 165 |
cycrow |
569 |
if ( pXspFile->anyCutData() )
|
| 1 |
cycrow |
570 |
{
|
| 306 |
cycrow |
571 |
wprintf(L"CutData Entries [%lu]:\n", static_cast<unsigned long>(pXspFile->getCutData().size()) );
|
| 165 |
cycrow |
572 |
for(auto itr = pXspFile->getCutData().begin(); itr != pXspFile->getCutData().end(); itr++)
|
| 216 |
cycrow |
573 |
wprintf(L"\t%s\n", (*itr)->str.c_str());
|
| 1 |
cycrow |
574 |
}
|
|
|
575 |
}
|
|
|
576 |
|
| 204 |
cycrow |
577 |
if ( !pBaseFile->creationDate().empty() ) wprintf(L"Creation Date: %s\n", pBaseFile->creationDate().c_str() );
|
| 206 |
cycrow |
578 |
if ( !pBaseFile->description().empty() ) wprintf(L"Description: %s\n", pBaseFile->description().c_str() );
|
| 1 |
cycrow |
579 |
if ( pSpkFile )
|
|
|
580 |
{
|
|
|
581 |
if ( pSpkFile->IsLibrary() )
|
|
|
582 |
printf ( "Script Type: Library\n" );
|
|
|
583 |
else if ( pSpkFile->IsPatch() )
|
|
|
584 |
printf ( "Script Type: Patch Mod\n" );
|
|
|
585 |
else if ( pSpkFile->IsCustomStart() )
|
|
|
586 |
printf ( "Script Type: Custom Start\n" );
|
|
|
587 |
else if ( pSpkFile->IsPackageUpdate() )
|
|
|
588 |
printf ( "Script Type: Package Update\n" );
|
| 214 |
cycrow |
589 |
else if ( !pSpkFile->scriptTypeString(44).empty() )
|
|
|
590 |
wprintf(L"Script Type: %s\n", pSpkFile->scriptTypeString(44).c_str() );
|
| 1 |
cycrow |
591 |
|
|
|
592 |
if ( !pSpkFile->GetWaresList()->empty() )
|
|
|
593 |
{
|
|
|
594 |
for ( CListNode<SWares> * wNode = pSpkFile->GetWaresList()->Front(); wNode; wNode = wNode->next() )
|
|
|
595 |
{
|
|
|
596 |
SWares *w = wNode->Data();
|
| 197 |
cycrow |
597 |
wprintf (L"Ware: (%c) %s\n", w->cType, CSpkFile::GetWareText(w, 44).c_str() );
|
|
|
598 |
Utils::WString desc = CSpkFile::GetWareDesc(w, 44);
|
|
|
599 |
if (!desc.empty())
|
|
|
600 |
wprintf(L"\tDescription: %s\n", desc.c_str() );
|
| 1 |
cycrow |
601 |
}
|
|
|
602 |
}
|
|
|
603 |
}
|
| 206 |
cycrow |
604 |
if ( !pBaseFile->forumLink().empty() ) wprintf(L"Forum Link: %s\n", pBaseFile->forumLink().c_str() );
|
|
|
605 |
if ( !pBaseFile->webSite().empty() ) wprintf(L"Web Site Address: %s\n", pBaseFile->webSite().c_str() );
|
|
|
606 |
if ( !pBaseFile->webAddress().empty() ) wprintf(L"Update Address: %s\n", pBaseFile->webAddress().c_str() );
|
| 1 |
cycrow |
607 |
|
| 162 |
cycrow |
608 |
if ( pBaseFile->anyWebMirrors() )
|
| 1 |
cycrow |
609 |
{
|
|
|
610 |
printf("Update Mirror Addresses:\n");
|
| 294 |
cycrow |
611 |
for (size_t i = 0; i < pBaseFile->getMaxWebMirrors(); i++ )
|
| 208 |
cycrow |
612 |
wprintf(L"\t%s\n", pBaseFile->getWebMirror(i).c_str());
|
| 1 |
cycrow |
613 |
}
|
|
|
614 |
if ( pSpkFile )
|
|
|
615 |
{
|
| 214 |
cycrow |
616 |
if ( (!pSpkFile->otherName().empty()) && (!pSpkFile->otherAuthor().empty()) )
|
|
|
617 |
wprintf(L"Script is a child to the mod: %s by %s\n", pSpkFile->otherName().c_str(), pSpkFile->otherAuthor().c_str() );
|
| 1 |
cycrow |
618 |
}
|
|
|
619 |
|
|
|
620 |
if ( pBaseFile->AnyDependacies() )
|
|
|
621 |
{
|
|
|
622 |
printf ( "Required Dependacies:\n" );
|
|
|
623 |
for ( SNeededLibrary *needed = pBaseFile->GetNeededLibraries()->First(); needed; needed = pBaseFile->GetNeededLibraries()->Next() )
|
| 204 |
cycrow |
624 |
wprintf(L"\t%s by %s (Minimum Version=%s)\n", needed->sName.c_str(), needed->sAuthor.c_str(), needed->sMinVersion.c_str() );
|
| 1 |
cycrow |
625 |
}
|
| 46 |
cycrow |
626 |
if ( pBaseFile->easeOfUse() != -1 ) printf ( "Ease Of Use Rating: %d\n", pBaseFile->easeOfUse() );
|
|
|
627 |
if ( pBaseFile->gameChanging() != -1 ) printf ( "Game Changing Rating: %d\n", pBaseFile->gameChanging() );
|
|
|
628 |
if ( pBaseFile->recommended() != -1 ) printf ( "Recommendation Rating: %d\n", pBaseFile->recommended() );
|
| 170 |
cycrow |
629 |
if (pBaseFile->icon())
|
| 197 |
cycrow |
630 |
wprintf(L"Icon File Found, Type: %s, Size: %s\n", pBaseFile->iconExt().c_str(), pBaseFile->icon()->dataSizeString().c_str() );
|
| 1 |
cycrow |
631 |
|
|
|
632 |
if ( pBaseFile->GetFileList()->size() )
|
|
|
633 |
{
|
| 134 |
cycrow |
634 |
printf("\nListing files in package:\n");
|
| 1 |
cycrow |
635 |
CLinkList<C_File> *list = pBaseFile->GetFileList();
|
| 134 |
cycrow |
636 |
|
|
|
637 |
for (unsigned int game = 0; game < 31; ++game)
|
|
|
638 |
{
|
|
|
639 |
bool heading = true;
|
|
|
640 |
for (C_File *file = list->First(); file; file = list->Next())
|
|
|
641 |
{
|
|
|
642 |
bool display = false;
|
|
|
643 |
if (game == 0 && (!file->game() || file->game() == GAME_ALLNEW))
|
|
|
644 |
display = true;
|
|
|
645 |
if (game > 0 && file->game() & (1 << game))
|
|
|
646 |
display = true;
|
|
|
647 |
|
|
|
648 |
if (display)
|
|
|
649 |
{
|
|
|
650 |
if (heading)
|
|
|
651 |
{
|
| 321 |
cycrow |
652 |
Utils::WString sGame = cmd.packages().gameExe()->gameNameFromType(game - 1);
|
| 197 |
cycrow |
653 |
wprintf(L"\tGame: %s\n", sGame.c_str());
|
| 134 |
cycrow |
654 |
heading = false;
|
|
|
655 |
}
|
| 197 |
cycrow |
656 |
wprintf(L"\t\t%s (%s) Size: %s\n", file->getNameDirectory(pBaseFile).c_str(), file->fileTypeString().c_str(), file->dataSizeString().c_str());
|
| 134 |
cycrow |
657 |
|
|
|
658 |
}
|
|
|
659 |
}
|
|
|
660 |
}
|
|
|
661 |
|
| 1 |
cycrow |
662 |
}
|
|
|
663 |
else
|
|
|
664 |
printf ( "\nThere are currently no files in the package\n" );
|
|
|
665 |
}
|
|
|
666 |
else if ( check == SPKFILE_MULTI )
|
|
|
667 |
{
|
|
|
668 |
CMultiSpkFile spkfile;
|
| 298 |
cycrow |
669 |
wprintf(L"* Opening Multi-SPK file, %s...\n", filename.c_str() );
|
| 175 |
cycrow |
670 |
if ( !pBaseFile->readFile(filename, false))
|
| 1 |
cycrow |
671 |
{
|
| 298 |
cycrow |
672 |
wprintf(L"Error: Failed to open the Multi-SPK file, %s\n", filename.c_str() );
|
| 1 |
cycrow |
673 |
return;
|
|
|
674 |
}
|
|
|
675 |
|
| 220 |
cycrow |
676 |
wprintf(L"Multi Package Name: %s\n", spkfile.name().c_str() );
|
| 298 |
cycrow |
677 |
wprintf(L"Selection Mode: " );
|
| 177 |
cycrow |
678 |
if (spkfile.isSelection ())
|
| 298 |
cycrow |
679 |
wprintf(L"On\n" );
|
| 1 |
cycrow |
680 |
else
|
| 298 |
cycrow |
681 |
wprintf(L"Off\n" );
|
| 1 |
cycrow |
682 |
|
|
|
683 |
CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
|
|
|
684 |
for ( SMultiSpkFile *ms = list->First(); ms; ms = list->Next() )
|
|
|
685 |
{
|
| 220 |
cycrow |
686 |
wprintf(L"File, %s:\n", ms->sName.c_str() );
|
| 197 |
cycrow |
687 |
wprintf(L"\tSize: %s\n", SPK::GetSizeString (ms->lSize).c_str() );
|
| 176 |
cycrow |
688 |
if ( (!ms->sScriptName.empty()) && (!ms->sScriptAuthor.empty()) )
|
| 220 |
cycrow |
689 |
wprintf(L"\tScript: %s %s by %s\n", ms->sScriptName.c_str(), ms->sScriptVersion.c_str(), ms->sScriptAuthor.c_str() );
|
| 298 |
cycrow |
690 |
wprintf(L"\tDefault Install: " );
|
| 1 |
cycrow |
691 |
if ( ms->bOn )
|
| 298 |
cycrow |
692 |
wprintf(L"Yes\n" );
|
| 1 |
cycrow |
693 |
else
|
| 298 |
cycrow |
694 |
wprintf(L"No\n" );
|
| 1 |
cycrow |
695 |
}
|
|
|
696 |
}
|
|
|
697 |
else
|
| 298 |
cycrow |
698 |
wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
|
| 1 |
cycrow |
699 |
|
|
|
700 |
if ( pBaseFile )
|
|
|
701 |
delete pBaseFile;
|
|
|
702 |
}
|
|
|
703 |
|
| 298 |
cycrow |
704 |
void AppendFile (const Utils::WString &sfile, const Utils::WString &type, const Utils::WString &addfile )
|
| 1 |
cycrow |
705 |
{
|
| 298 |
cycrow |
706 |
int t = GetFileTypeFromString(type);
|
| 1 |
cycrow |
707 |
if ( t == -1 )
|
|
|
708 |
{
|
| 298 |
cycrow |
709 |
wprintf(L"The file type \"%s\" is invalid\n", type.c_str());
|
| 1 |
cycrow |
710 |
return;
|
|
|
711 |
}
|
|
|
712 |
|
| 298 |
cycrow |
713 |
int check = CSpkFile::CheckFile(sfile);
|
| 1 |
cycrow |
714 |
CBaseFile *pBaseFile = 0;
|
|
|
715 |
if ( check == SPKFILE_SINGLE )
|
|
|
716 |
pBaseFile = new CSpkFile();
|
|
|
717 |
else if ( check == SPKFILE_SINGLESHIP )
|
|
|
718 |
pBaseFile = new CXspFile();
|
|
|
719 |
else if ( check == SPKFILE_BASE )
|
|
|
720 |
pBaseFile = new CBaseFile();
|
|
|
721 |
|
|
|
722 |
if ( !pBaseFile )
|
|
|
723 |
{
|
| 298 |
cycrow |
724 |
wprintf(L"Error: Invalid file format, unable to open\n");
|
| 1 |
cycrow |
725 |
return;
|
|
|
726 |
}
|
|
|
727 |
|
| 298 |
cycrow |
728 |
wprintf(L"Opening File, %s... ", sfile.c_str());
|
|
|
729 |
if ( !pBaseFile->readFile(sfile))
|
| 1 |
cycrow |
730 |
{
|
| 298 |
cycrow |
731 |
wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str());
|
| 1 |
cycrow |
732 |
return;
|
|
|
733 |
}
|
| 298 |
cycrow |
734 |
wprintf(L"(Done)\n" );
|
| 1 |
cycrow |
735 |
|
|
|
736 |
MyProgress progress(0);
|
|
|
737 |
|
| 298 |
cycrow |
738 |
wprintf(L"Adding file %s to package\n\t>", addfile.c_str() );
|
| 1 |
cycrow |
739 |
|
| 298 |
cycrow |
740 |
if ( pBaseFile->appendFile(addfile, t, 0, false, Utils::WString::Null(), &progress))
|
| 1 |
cycrow |
741 |
{
|
|
|
742 |
progress.PrintDone();
|
| 298 |
cycrow |
743 |
wprintf(L"< (Done)\n");
|
| 1 |
cycrow |
744 |
|
| 298 |
cycrow |
745 |
pBaseFile->writeFile(sfile);
|
|
|
746 |
wprintf(L"\nFile has been written sucessfully\n");
|
| 1 |
cycrow |
747 |
}
|
|
|
748 |
else
|
| 298 |
cycrow |
749 |
wprintf(L"< (Error)\n");
|
| 1 |
cycrow |
750 |
}
|
|
|
751 |
|
| 298 |
cycrow |
752 |
void RemoveFile(const Utils::WString &sfile, const Utils::WString &type, const Utils::WString &addfile)
|
| 1 |
cycrow |
753 |
{
|
| 298 |
cycrow |
754 |
FILE *id = _wfopen(sfile.c_str(), L"rb+");
|
| 1 |
cycrow |
755 |
if ( !id )
|
|
|
756 |
{
|
| 298 |
cycrow |
757 |
wprintf(L"Error: File, %s, doesn't exist\n", sfile.c_str() );
|
| 1 |
cycrow |
758 |
return;
|
|
|
759 |
}
|
|
|
760 |
|
| 298 |
cycrow |
761 |
if ( addfile.empty() )
|
| 1 |
cycrow |
762 |
{
|
| 298 |
cycrow |
763 |
wprintf(L"Error: Remove filename is invalid\n" );
|
| 1 |
cycrow |
764 |
return;
|
|
|
765 |
}
|
| 298 |
cycrow |
766 |
FileType t = GetFileTypeFromString(type);
|
| 172 |
cycrow |
767 |
if (t == FileType::FILETYPE_UNKNOWN)
|
| 1 |
cycrow |
768 |
{
|
| 298 |
cycrow |
769 |
wprintf(L"The file type \"%s\" is invalid\n", type.c_str() );
|
| 1 |
cycrow |
770 |
return;
|
|
|
771 |
}
|
|
|
772 |
|
| 298 |
cycrow |
773 |
int check = CSpkFile::CheckFile(sfile);
|
| 1 |
cycrow |
774 |
CBaseFile *pBaseFile = 0;
|
|
|
775 |
if ( check == SPKFILE_SINGLE )
|
|
|
776 |
pBaseFile = new CSpkFile();
|
|
|
777 |
else if ( check == SPKFILE_SINGLESHIP )
|
|
|
778 |
pBaseFile = new CXspFile();
|
|
|
779 |
else if ( check == SPKFILE_BASE )
|
|
|
780 |
pBaseFile = new CBaseFile();
|
|
|
781 |
|
|
|
782 |
if ( pBaseFile )
|
|
|
783 |
{
|
| 298 |
cycrow |
784 |
wprintf(L"Opening File, %s... ", sfile.c_str());
|
|
|
785 |
if ( !pBaseFile->readFile(sfile))
|
| 1 |
cycrow |
786 |
{
|
| 298 |
cycrow |
787 |
wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str());
|
| 1 |
cycrow |
788 |
return;
|
|
|
789 |
}
|
| 298 |
cycrow |
790 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
791 |
|
| 298 |
cycrow |
792 |
wprintf(L"Removing file, %s, from Package\n", addfile.c_str());
|
| 1 |
cycrow |
793 |
|
| 298 |
cycrow |
794 |
if(pBaseFile->removeFile(addfile, t))
|
| 1 |
cycrow |
795 |
{
|
| 298 |
cycrow |
796 |
wprintf(L"File, %s, has been remove from package\n", addfile.c_str() );
|
|
|
797 |
pBaseFile->writeFile(sfile);
|
|
|
798 |
wprintf(L"File has been written to disk successfully\n" );
|
| 1 |
cycrow |
799 |
}
|
|
|
800 |
else
|
| 298 |
cycrow |
801 |
wprintf(L"Unable to remove the file, %s, from the package\n", addfile.c_str());
|
| 1 |
cycrow |
802 |
}
|
|
|
803 |
else if ( check == SPKFILE_MULTI )
|
|
|
804 |
{
|
|
|
805 |
CMultiSpkFile spkfile;
|
| 298 |
cycrow |
806 |
wprintf(L"Opening Multi-SPK file, %s...", sfile.c_str());
|
|
|
807 |
if ( !spkfile.readFile(sfile))
|
| 1 |
cycrow |
808 |
{
|
| 298 |
cycrow |
809 |
wprintf(L"(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str());
|
| 1 |
cycrow |
810 |
return;
|
|
|
811 |
}
|
| 298 |
cycrow |
812 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
813 |
|
| 298 |
cycrow |
814 |
const SMultiSpkFile *ms = spkfile.findFile(type);
|
| 1 |
cycrow |
815 |
if ( !ms )
|
|
|
816 |
{
|
| 298 |
cycrow |
817 |
wprintf(L"Unable to find the file \"%s\" in the package\n", type.c_str());
|
| 1 |
cycrow |
818 |
return;
|
|
|
819 |
}
|
|
|
820 |
|
| 298 |
cycrow |
821 |
wprintf(L"Removing file, %s, from Package\n", addfile.c_str());
|
| 177 |
cycrow |
822 |
if (!spkfile.removeFile(ms))
|
| 1 |
cycrow |
823 |
{
|
| 298 |
cycrow |
824 |
wprintf(L"Error: Unable to remove file, %s, from package\n", type.c_str());
|
| 1 |
cycrow |
825 |
return;
|
|
|
826 |
}
|
|
|
827 |
|
| 298 |
cycrow |
828 |
wprintf(L"Writing SPK File, %s... ", sfile.c_str());
|
|
|
829 |
if (spkfile.writeFile(sfile))
|
|
|
830 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
831 |
else
|
| 298 |
cycrow |
832 |
wprintf(L"(Error)\n");
|
| 1 |
cycrow |
833 |
}
|
|
|
834 |
else
|
| 298 |
cycrow |
835 |
wprintf(L"Error: Invalid file format, unable to open\n");
|
| 1 |
cycrow |
836 |
}
|
|
|
837 |
|
|
|
838 |
|
| 298 |
cycrow |
839 |
void CreateMultiFile (const Utils::WString &filename)
|
| 1 |
cycrow |
840 |
{
|
| 298 |
cycrow |
841 |
wprintf(L"* Creating new Multi-SPK File, %s\n\n", filename.c_str());
|
| 1 |
cycrow |
842 |
|
| 298 |
cycrow |
843 |
FILE *id = _wfopen(filename.c_str(), L"rb+");
|
| 1 |
cycrow |
844 |
if ( id )
|
|
|
845 |
{
|
|
|
846 |
fclose ( id );
|
| 298 |
cycrow |
847 |
wprintf(L"* File already exists, unable to create\n");
|
| 1 |
cycrow |
848 |
return;
|
|
|
849 |
}
|
|
|
850 |
|
| 298 |
cycrow |
851 |
id = _wfopen(filename.c_str(), L"wb");
|
| 1 |
cycrow |
852 |
if ( !id )
|
|
|
853 |
{
|
| 298 |
cycrow |
854 |
wprintf(L"* Unable to open file for writing\n");
|
| 1 |
cycrow |
855 |
return;
|
|
|
856 |
}
|
| 298 |
cycrow |
857 |
fclose(id);
|
|
|
858 |
_wremove(filename.c_str());
|
| 1 |
cycrow |
859 |
|
|
|
860 |
CMultiSpkFile spkfile;
|
|
|
861 |
|
| 197 |
cycrow |
862 |
Utils::WString sInput;
|
| 298 |
cycrow |
863 |
wprintf(L"Enter Multi-Spk Package Name: ");
|
|
|
864 |
spkfile.setName(GetInput());
|
| 1 |
cycrow |
865 |
|
|
|
866 |
while ( true )
|
|
|
867 |
{
|
| 298 |
cycrow |
868 |
wprintf(L"\nDo you want users to select scripts to install? (Y/N): " );
|
| 197 |
cycrow |
869 |
Utils::WString i = GetInput();
|
|
|
870 |
i = i.upper();
|
|
|
871 |
if ( i == L"Y" )
|
| 177 |
cycrow |
872 |
spkfile.setSelection(true);
|
| 197 |
cycrow |
873 |
if ( (i == L"Y") || (i == L"N") )
|
| 1 |
cycrow |
874 |
break;
|
|
|
875 |
}
|
|
|
876 |
|
|
|
877 |
while ( true )
|
|
|
878 |
{
|
| 298 |
cycrow |
879 |
wprintf(L"\nEnter Spk File to add (Enter \"0\" to finish): " );
|
| 1 |
cycrow |
880 |
sInput = GetInput();
|
| 226 |
cycrow |
881 |
if ( sInput == L"0" )
|
| 1 |
cycrow |
882 |
break;
|
|
|
883 |
|
|
|
884 |
// check if file can be opened
|
| 298 |
cycrow |
885 |
FILE *id2 = _wfopen(sInput.c_str(), L"rb+");
|
| 1 |
cycrow |
886 |
if ( !id2 )
|
| 197 |
cycrow |
887 |
wprintf(L"Error: Unable to open SPK file %s\n", sInput.c_str() );
|
| 1 |
cycrow |
888 |
else
|
|
|
889 |
{
|
| 298 |
cycrow |
890 |
fclose(id2);
|
|
|
891 |
if ( !spkfile.addFile(sInput))
|
|
|
892 |
wprintf(L"Error: Unable to add SPK file to package\n");
|
| 1 |
cycrow |
893 |
else
|
| 298 |
cycrow |
894 |
wprintf(L"File Added to package (%s)\n", sInput.c_str());
|
| 1 |
cycrow |
895 |
}
|
|
|
896 |
}
|
|
|
897 |
|
| 177 |
cycrow |
898 |
if ( spkfile.numFiles() < 1 )
|
| 298 |
cycrow |
899 |
wprintf(L"\nError: You have added no files, you must add at least one file to create a package\n");
|
| 1 |
cycrow |
900 |
else
|
|
|
901 |
{
|
| 298 |
cycrow |
902 |
wprintf(L"Writing MultiSpk file... ");
|
|
|
903 |
if ( spkfile.writeFile(filename))
|
|
|
904 |
wprintf(L"(Done)\n" );
|
| 1 |
cycrow |
905 |
else
|
| 298 |
cycrow |
906 |
wprintf(L"(Error)\n" );
|
| 1 |
cycrow |
907 |
}
|
|
|
908 |
|
|
|
909 |
}
|
|
|
910 |
|
| 298 |
cycrow |
911 |
void CreateFile(const Utils::WString &filename)
|
| 1 |
cycrow |
912 |
{
|
| 298 |
cycrow |
913 |
wprintf(L"* Creating new SPK File, %s\n\n", filename.c_str());
|
| 1 |
cycrow |
914 |
|
| 298 |
cycrow |
915 |
FILE *id = _wfopen(filename.c_str(), L"rb+");
|
| 1 |
cycrow |
916 |
if ( id )
|
|
|
917 |
{
|
| 298 |
cycrow |
918 |
fclose(id);
|
|
|
919 |
wprintf(L"* File already exists, unable to create\n");
|
| 1 |
cycrow |
920 |
return;
|
|
|
921 |
}
|
|
|
922 |
|
| 298 |
cycrow |
923 |
id = _wfopen(filename.c_str(), L"wb");
|
| 1 |
cycrow |
924 |
if ( !id )
|
|
|
925 |
{
|
| 298 |
cycrow |
926 |
wprintf(L"* Unable to open file for writing\n");
|
| 1 |
cycrow |
927 |
return;
|
|
|
928 |
}
|
| 298 |
cycrow |
929 |
fclose(id);
|
|
|
930 |
_wremove(filename.c_str());
|
| 1 |
cycrow |
931 |
|
|
|
932 |
CSpkFile spkfile;
|
|
|
933 |
|
| 298 |
cycrow |
934 |
wprintf(L"Enter Script Name: ");
|
|
|
935 |
spkfile.setName(GetInput());
|
| 1 |
cycrow |
936 |
|
| 298 |
cycrow |
937 |
wprintf(L"Enter Script Author: ");
|
|
|
938 |
spkfile.setAuthor(GetInput());
|
| 1 |
cycrow |
939 |
|
| 298 |
cycrow |
940 |
wprintf(L"Enter Script Version: ");
|
|
|
941 |
spkfile.setVersion(GetInput());
|
| 1 |
cycrow |
942 |
|
| 298 |
cycrow |
943 |
wprintf(L"Enter Script Description: ");
|
|
|
944 |
spkfile.setDescription(GetInput());
|
| 1 |
cycrow |
945 |
|
|
|
946 |
struct tm *currDate;
|
|
|
947 |
char dateString[100];
|
|
|
948 |
time_t now = time(NULL);
|
|
|
949 |
|
|
|
950 |
currDate = localtime( &now );
|
|
|
951 |
strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
|
| 226 |
cycrow |
952 |
spkfile.setCreationDate(Utils::WString::FromString(dateString));
|
| 1 |
cycrow |
953 |
|
| 298 |
cycrow |
954 |
spkfile.writeFile(filename, NULL);
|
|
|
955 |
wprintf(L"SPK file has been written to disk: %s\n", filename.c_str() );
|
| 1 |
cycrow |
956 |
}
|
|
|
957 |
|
| 315 |
cycrow |
958 |
void ExtractFiles (const Utils::CommandLine &cmd)
|
| 1 |
cycrow |
959 |
{
|
| 315 |
cycrow |
960 |
const Utils::WString& sfile = cmd.arg(1);
|
|
|
961 |
const Utils::WString & dir = cmd.arg(2);
|
|
|
962 |
int game = (cmd.hasSwitch(L"game")) ? CBaseFile::GetGameFromString(cmd.switchData(L"game")) : 0;
|
|
|
963 |
|
| 1 |
cycrow |
964 |
// First checks if the file exists by opening it
|
| 315 |
cycrow |
965 |
CFileIO File(sfile);
|
|
|
966 |
if (!File.exists())
|
|
|
967 |
File.open(CDirIO(g_dir).file(sfile));
|
|
|
968 |
if (!File.exists())
|
| 1 |
cycrow |
969 |
{
|
| 298 |
cycrow |
970 |
wprintf(L"Error: File, %s, doesn't exist\n", sfile.c_str() );
|
| 1 |
cycrow |
971 |
return;
|
|
|
972 |
}
|
|
|
973 |
|
| 315 |
cycrow |
974 |
int check = CSpkFile::CheckFile(File.fullFilename());
|
| 1 |
cycrow |
975 |
|
|
|
976 |
// extracts a file from single packages file
|
|
|
977 |
if ( check == SPKFILE_SINGLE || check == SPKFILE_BASE || check == SPKFILE_SINGLESHIP )
|
|
|
978 |
{
|
|
|
979 |
// creates the spkfile object
|
|
|
980 |
CBaseFile *pBaseFile = 0;
|
|
|
981 |
if ( check == SPKFILE_SINGLE )
|
|
|
982 |
pBaseFile = (CBaseFile *)new CSpkFile();
|
|
|
983 |
else if ( check == SPKFILE_SINGLESHIP )
|
|
|
984 |
pBaseFile = (CBaseFile *)new CXspFile();
|
|
|
985 |
else
|
|
|
986 |
pBaseFile = new CBaseFile();
|
|
|
987 |
|
| 298 |
cycrow |
988 |
wprintf(L"Opening File, %s... ", sfile.c_str());
|
| 1 |
cycrow |
989 |
// reads the file into memory
|
|
|
990 |
// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
|
| 315 |
cycrow |
991 |
if ( !pBaseFile->readFile(File.fullFilename(), SPKREAD_NODATA))
|
| 1 |
cycrow |
992 |
{
|
| 298 |
cycrow |
993 |
wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str() );
|
| 1 |
cycrow |
994 |
return;
|
|
|
995 |
}
|
| 298 |
cycrow |
996 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
997 |
|
| 134 |
cycrow |
998 |
if(game == 0)
|
| 298 |
cycrow |
999 |
wprintf(L"Extracting all files from archive...\n\n");
|
| 1 |
cycrow |
1000 |
else
|
| 321 |
cycrow |
1001 |
wprintf(L"Extracting %s files from archive...\n\n", cmd.packages().gameExe()->gameNameFromType(game - 1).c_str());
|
| 134 |
cycrow |
1002 |
|
| 321 |
cycrow |
1003 |
CFileProgress info(&cmd.packages(), pBaseFile, "Extracting");
|
|
|
1004 |
if (cmd.packages().extractAll(pBaseFile, File.dirIO().dir(dir), game, true, &info))
|
| 298 |
cycrow |
1005 |
wprintf(L"\n(Done)\nFiles have been extracted successfully\n");
|
| 134 |
cycrow |
1006 |
else
|
| 298 |
cycrow |
1007 |
wprintf(L"\n(Error)\nThere was a problem extracting the files\n");
|
| 1 |
cycrow |
1008 |
}
|
|
|
1009 |
else
|
| 298 |
cycrow |
1010 |
wprintf(L"Invalid package file, %s\n", sfile.c_str());
|
| 1 |
cycrow |
1011 |
}
|
|
|
1012 |
|
|
|
1013 |
|
|
|
1014 |
/*
|
|
|
1015 |
Func: AppendMultiFile
|
|
|
1016 |
Args: String toFile - The spk file to append onto
|
|
|
1017 |
String addfile - The spk file to append
|
|
|
1018 |
Desc: Appends a spk file into a Multi-Spk Archive
|
|
|
1019 |
If toFile is a single spk file, it will be converted to a Multi-Spk File
|
|
|
1020 |
if addfile is a Multi-Spk file, all files from it will be appended
|
|
|
1021 |
*/
|
| 298 |
cycrow |
1022 |
void AppendMultiFile(const Utils::WString &toFile, const Utils::WString &addfile)
|
| 1 |
cycrow |
1023 |
{
|
|
|
1024 |
// create destination object
|
|
|
1025 |
CMultiSpkFile spkfile;
|
|
|
1026 |
|
|
|
1027 |
// checks the destination
|
| 298 |
cycrow |
1028 |
int checkto = CSpkFile::CheckFile(toFile);
|
| 1 |
cycrow |
1029 |
|
|
|
1030 |
// if the destination is a single file, then convert it to a Multi-Spk package
|
|
|
1031 |
if ( checkto == SPKFILE_SINGLE )
|
|
|
1032 |
{
|
|
|
1033 |
// adds the single file to the Multi-Spk object
|
|
|
1034 |
// Add file also reads it into memory
|
| 298 |
cycrow |
1035 |
if ( !spkfile.addFile(toFile))
|
| 1 |
cycrow |
1036 |
{
|
| 298 |
cycrow |
1037 |
wprintf(L"Error: Unable to create Multi-Spk file\n");
|
| 1 |
cycrow |
1038 |
return;
|
|
|
1039 |
}
|
|
|
1040 |
}
|
|
|
1041 |
else
|
|
|
1042 |
{
|
|
|
1043 |
// if its already a multispk file, then simply open it and read it to memory
|
| 298 |
cycrow |
1044 |
if ( !spkfile.readFile(toFile))
|
| 1 |
cycrow |
1045 |
{
|
| 298 |
cycrow |
1046 |
wprintf(L"Error: Unable to open Multi-Spk file, %s\n", toFile.c_str());
|
| 1 |
cycrow |
1047 |
return;
|
|
|
1048 |
}
|
|
|
1049 |
}
|
|
|
1050 |
|
|
|
1051 |
// now add the file into the Multi-Spk Object
|
|
|
1052 |
// the AddFile function will handle both single and Multi-Spk files
|
|
|
1053 |
// So you dont need to test what the appending file is
|
| 298 |
cycrow |
1054 |
if ( spkfile.addFile(addfile))
|
| 1 |
cycrow |
1055 |
{
|
|
|
1056 |
|
|
|
1057 |
// if it added correctly, then simply write the new Multi-Spk Object to disk
|
| 298 |
cycrow |
1058 |
wprintf(L"File, %s, has been added to Multi-Spk Package\n", addfile.c_str());
|
|
|
1059 |
wprintf(L"Saving Multi-Spk File: %s... ", toFile.c_str());
|
|
|
1060 |
if ( spkfile.writeFile(toFile))
|
|
|
1061 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
1062 |
else
|
| 298 |
cycrow |
1063 |
wprintf(L"(Error)\n");
|
| 1 |
cycrow |
1064 |
}
|
|
|
1065 |
else
|
| 298 |
cycrow |
1066 |
wprintf(L"Error: Unable to add files, %s, to Multi-Spk Package\n", addfile.c_str());
|
| 1 |
cycrow |
1067 |
}
|
|
|
1068 |
|
|
|
1069 |
/*
|
|
|
1070 |
Func: ExtractFile
|
|
|
1071 |
Args: String sfile - the spk file to read from
|
|
|
1072 |
String type - the type of the file to find
|
|
|
1073 |
String addfile - The filename to extract
|
|
|
1074 |
String dir - The directory to extract to
|
|
|
1075 |
Desc: Finds and extracts a file from a Spk Package
|
|
|
1076 |
*/
|
| 298 |
cycrow |
1077 |
void ExtractFile (const Utils::WString &sfile, const Utils::WString &type, const Utils::WString &addfile, const Utils::WString &dir)
|
| 1 |
cycrow |
1078 |
{
|
|
|
1079 |
// First checks if the file exists by opening it
|
| 298 |
cycrow |
1080 |
FILE *id = _wfopen(sfile.c_str(), L"rb+");
|
| 1 |
cycrow |
1081 |
if ( !id )
|
|
|
1082 |
{
|
| 298 |
cycrow |
1083 |
wprintf(L"Error: File, %s, doesn't exist\n", sfile.c_str());
|
| 1 |
cycrow |
1084 |
return;
|
|
|
1085 |
}
|
|
|
1086 |
fclose ( id );
|
|
|
1087 |
|
|
|
1088 |
// now check the type of file it is, using the static function CheckFile(filename).
|
|
|
1089 |
// This will return the type of file
|
|
|
1090 |
// SPK_INVALID - Invalid file format, wont be able to open
|
|
|
1091 |
// SPK_SINGLE - A Single spk package file
|
|
|
1092 |
// SPK_MULTI - A Multi-Spk Archive
|
|
|
1093 |
// SPK_BASE - A Base File
|
|
|
1094 |
// SPK_SINGLESHIP - A Ship file
|
|
|
1095 |
int check = CSpkFile::CheckFile ( sfile );
|
|
|
1096 |
|
|
|
1097 |
// extracts a file from single packages file
|
|
|
1098 |
if ( check == SPKFILE_SINGLE || check == SPKFILE_BASE || check == SPKFILE_SINGLESHIP )
|
|
|
1099 |
{
|
|
|
1100 |
// first get the file type is valid
|
|
|
1101 |
// converts the string type into its filetype flag
|
| 170 |
cycrow |
1102 |
FileType t = GetFileTypeFromString(type);
|
| 1 |
cycrow |
1103 |
// incorrect text type, display the error
|
| 170 |
cycrow |
1104 |
if (t == FileType::FILETYPE_UNKNOWN)
|
| 1 |
cycrow |
1105 |
{
|
| 298 |
cycrow |
1106 |
wprintf(L"The file type \"%s\" is invalid\n", type.c_str());
|
| 1 |
cycrow |
1107 |
return;
|
|
|
1108 |
}
|
|
|
1109 |
|
|
|
1110 |
// creates the spkfile object
|
|
|
1111 |
CBaseFile *pBaseFile = 0;
|
|
|
1112 |
if ( check == SPKFILE_SINGLE )
|
|
|
1113 |
pBaseFile = (CBaseFile *)new CSpkFile();
|
|
|
1114 |
else if ( check == SPKFILE_SINGLESHIP )
|
|
|
1115 |
pBaseFile = (CBaseFile *)new CXspFile();
|
|
|
1116 |
else
|
|
|
1117 |
pBaseFile = new CBaseFile();
|
|
|
1118 |
|
| 298 |
cycrow |
1119 |
wprintf(L"Opening File, %s... ", sfile.c_str());
|
| 1 |
cycrow |
1120 |
// reads the file into memory
|
|
|
1121 |
// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
|
| 175 |
cycrow |
1122 |
if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
|
| 1 |
cycrow |
1123 |
{
|
| 298 |
cycrow |
1124 |
wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str());
|
| 1 |
cycrow |
1125 |
return;
|
|
|
1126 |
}
|
|
|
1127 |
|
|
|
1128 |
// No read all the file data into memory
|
|
|
1129 |
// This can be done all together in the ReadFile function
|
|
|
1130 |
// Doing it seperatly allows you to save time if an error occurs, so you dont have to wait for it to read the whole thing
|
|
|
1131 |
pBaseFile->ReadAllFilesToMemory ();
|
|
|
1132 |
|
| 298 |
cycrow |
1133 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
1134 |
|
|
|
1135 |
// uses the FindFile function to find the selected file in the archive
|
|
|
1136 |
// requires the filename, type and custom directory (only for Extra File Type)
|
| 170 |
cycrow |
1137 |
C_File *f = pBaseFile->findFile(addfile, t);
|
| 1 |
cycrow |
1138 |
if ( !f )
|
|
|
1139 |
{
|
| 298 |
cycrow |
1140 |
wprintf(L"Unable to find the file \"%s\" in the package\n", addfile.c_str());
|
| 1 |
cycrow |
1141 |
return;
|
|
|
1142 |
}
|
|
|
1143 |
|
|
|
1144 |
// creates the directory so it can be extracted
|
|
|
1145 |
CDirIO Dir(dir);
|
| 160 |
cycrow |
1146 |
if ( !Dir.create(f->getDirectory(pBaseFile)) )
|
| 1 |
cycrow |
1147 |
{
|
| 298 |
cycrow |
1148 |
wprintf(L"Unable to create the directory \"%s\" to extract into\n", dir.c_str());
|
| 1 |
cycrow |
1149 |
return;
|
|
|
1150 |
}
|
|
|
1151 |
|
|
|
1152 |
// sets up the progress pointer
|
|
|
1153 |
// if it uses 7zip, the progress will be displayed in the command prompt
|
|
|
1154 |
MyProgress progress(0);
|
| 298 |
cycrow |
1155 |
wprintf(L"Extracting the file from package\n\t>");
|
| 1 |
cycrow |
1156 |
|
|
|
1157 |
// Extracts the file to the specified directory
|
| 175 |
cycrow |
1158 |
if ( !pBaseFile->extractFile(f, dir, true, &progress))
|
| 298 |
cycrow |
1159 |
wprintf(L"< (Error)\nUnable to extract the file\n");
|
| 1 |
cycrow |
1160 |
else
|
|
|
1161 |
{
|
|
|
1162 |
progress.PrintDone ();
|
| 298 |
cycrow |
1163 |
wprintf(L"< (Done)\nFile has been extracted successfully\n");
|
| 1 |
cycrow |
1164 |
}
|
|
|
1165 |
}
|
|
|
1166 |
|
|
|
1167 |
// the file is a Multi-Spk File, extracts a single spk file from the archive
|
|
|
1168 |
else if ( check == SPKFILE_MULTI )
|
|
|
1169 |
{
|
|
|
1170 |
// creates MultiSpkFile object
|
|
|
1171 |
CMultiSpkFile spkfile;
|
| 298 |
cycrow |
1172 |
wprintf(L"Opening Multi-SPK file, %s...", sfile.c_str());
|
| 1 |
cycrow |
1173 |
|
|
|
1174 |
// reads the MultiSpkFile into memory
|
| 177 |
cycrow |
1175 |
if ( !spkfile.readFile(sfile))
|
| 1 |
cycrow |
1176 |
{
|
| 298 |
cycrow |
1177 |
wprintf(L"(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str());
|
| 1 |
cycrow |
1178 |
return;
|
|
|
1179 |
}
|
| 298 |
cycrow |
1180 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
1181 |
|
|
|
1182 |
// searchs the archive for a matching file
|
| 177 |
cycrow |
1183 |
const SMultiSpkFile *ms = spkfile.findFile(type);
|
| 1 |
cycrow |
1184 |
if ( !ms )
|
|
|
1185 |
{
|
| 298 |
cycrow |
1186 |
wprintf(L"Unable to find the file \"%s\" in the package\n", type.c_str());
|
| 1 |
cycrow |
1187 |
return;
|
|
|
1188 |
}
|
|
|
1189 |
|
|
|
1190 |
// extracts the file from the archive, to the given directory
|
| 298 |
cycrow |
1191 |
wprintf(L"Extracting SPK file, %s, from package... ", ms->sName.c_str());
|
| 177 |
cycrow |
1192 |
if (spkfile.extractFile(ms, addfile))
|
| 298 |
cycrow |
1193 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
1194 |
else
|
| 298 |
cycrow |
1195 |
wprintf(L"(Error)\n");
|
| 1 |
cycrow |
1196 |
}
|
|
|
1197 |
else
|
| 298 |
cycrow |
1198 |
wprintf(L"Error: Invalid file format, unable to open\n");
|
| 1 |
cycrow |
1199 |
}
|
|
|
1200 |
|
|
|
1201 |
/*
|
|
|
1202 |
Func: SplitMulti
|
|
|
1203 |
Args: String filename - the filename of the multispk file to open
|
|
|
1204 |
String dest - The destination directory to extract the files to
|
|
|
1205 |
Desc: Splits a multi-spk file into its seperate spk files
|
|
|
1206 |
*/
|
| 298 |
cycrow |
1207 |
void SplitMulti(const Utils::WString &filename, const Utils::WString &dest)
|
| 1 |
cycrow |
1208 |
{
|
|
|
1209 |
// Check the file type, Must return SPKFILE_MULTI, otherwise its not a Multi-Spk Packages
|
| 298 |
cycrow |
1210 |
if ( CSpkFile::CheckFile(filename) != SPKFILE_MULTI )
|
| 1 |
cycrow |
1211 |
{
|
| 298 |
cycrow |
1212 |
wprintf(L"Error: The file is not a Multi-Spk packages\n");
|
| 1 |
cycrow |
1213 |
return;
|
|
|
1214 |
}
|
|
|
1215 |
|
| 298 |
cycrow |
1216 |
wprintf(L"Spliting Multi-SPK File to, %s... ", dest.c_str());
|
| 1 |
cycrow |
1217 |
|
|
|
1218 |
// create the MultiSpkFile object
|
|
|
1219 |
CMultiSpkFile spkfile;
|
|
|
1220 |
|
|
|
1221 |
// Splits the files to the destination
|
| 298 |
cycrow |
1222 |
if ( !spkfile.splitMulti(filename, dest))
|
| 1 |
cycrow |
1223 |
{
|
| 298 |
cycrow |
1224 |
wprintf(L"(Error)\nUnable to split Multi-SPK package, %s\n", filename.c_str());
|
| 1 |
cycrow |
1225 |
return;
|
|
|
1226 |
}
|
|
|
1227 |
|
| 298 |
cycrow |
1228 |
wprintf(L"(Done)\n");
|
| 1 |
cycrow |
1229 |
}
|
|
|
1230 |
|
| 197 |
cycrow |
1231 |
Utils::WString GetAsk(const Utils::WString &command)
|
| 1 |
cycrow |
1232 |
{
|
| 197 |
cycrow |
1233 |
wprintf(L"(ASK) Enter the value for, %s: ", command.c_str());
|
| 1 |
cycrow |
1234 |
return GetInput();
|
|
|
1235 |
}
|
|
|
1236 |
|
| 321 |
cycrow |
1237 |
void GenerateUpdateList(const Utils::CommandLine &cmd)
|
| 126 |
cycrow |
1238 |
{
|
| 196 |
cycrow |
1239 |
Utils::WStringList list;
|
| 321 |
cycrow |
1240 |
for (int i = 1; i < cmd.argCount(); ++i)
|
| 126 |
cycrow |
1241 |
{
|
| 321 |
cycrow |
1242 |
Utils::WString file(cmd.arg(i));
|
| 126 |
cycrow |
1243 |
if (CFileIO::Exists(file))
|
| 196 |
cycrow |
1244 |
list.pushBack(file, L"file");
|
| 321 |
cycrow |
1245 |
else if (CFileIO::Exists(cmd.dirIO().file(file)))
|
|
|
1246 |
list.pushBack(cmd.dirIO().file(file), L"file");
|
| 126 |
cycrow |
1247 |
else if (CDirIO::Exists(file))
|
| 196 |
cycrow |
1248 |
list.pushBack(file, L"dir");
|
| 321 |
cycrow |
1249 |
else if (CDirIO::Exists(cmd.dirIO().dir(file)))
|
|
|
1250 |
list.pushBack(cmd.dirIO().dir(file), L"dir");
|
| 126 |
cycrow |
1251 |
else
|
| 196 |
cycrow |
1252 |
list.pushBack(file, L"pattern");
|
| 126 |
cycrow |
1253 |
}
|
|
|
1254 |
|
|
|
1255 |
if (list.empty())
|
| 298 |
cycrow |
1256 |
wprintf(L"unable to find any packages");
|
| 126 |
cycrow |
1257 |
else
|
|
|
1258 |
{
|
| 196 |
cycrow |
1259 |
Utils::WStringList fileList;
|
| 126 |
cycrow |
1260 |
for (auto itr = list.begin(); itr != list.end(); itr++)
|
|
|
1261 |
{
|
| 196 |
cycrow |
1262 |
Utils::WString file = (*itr)->str;
|
|
|
1263 |
Utils::WString data = (*itr)->data;
|
|
|
1264 |
if (data == L"file")
|
| 126 |
cycrow |
1265 |
fileList.pushBack(file);
|
| 196 |
cycrow |
1266 |
else if (data == L"dir")
|
| 126 |
cycrow |
1267 |
{
|
|
|
1268 |
CDirIO dir(file);
|
| 196 |
cycrow |
1269 |
Utils::WStringList d;
|
| 126 |
cycrow |
1270 |
if (dir.dirList(d))
|
|
|
1271 |
{
|
|
|
1272 |
for (auto itr2 = d.begin(); itr2 != d.end(); itr2++)
|
|
|
1273 |
{
|
| 196 |
cycrow |
1274 |
Utils::WString ext = CFileIO((*itr2)->str).extension().lower();
|
|
|
1275 |
if(ext == L"xsp" || ext == L"spk")
|
| 126 |
cycrow |
1276 |
fileList.pushBack(dir.file((*itr2)->str));
|
|
|
1277 |
}
|
|
|
1278 |
}
|
|
|
1279 |
}
|
| 226 |
cycrow |
1280 |
else if (data == L"pattern")
|
| 126 |
cycrow |
1281 |
{
|
|
|
1282 |
CFileIO f(file);
|
|
|
1283 |
CDirIO dir(f.dir());
|
|
|
1284 |
|
|
|
1285 |
if (!dir.exists())
|
| 321 |
cycrow |
1286 |
dir = CDirIO(cmd.dirIO().dir(dir.dir()));
|
| 126 |
cycrow |
1287 |
|
| 196 |
cycrow |
1288 |
Utils::WStringList d;
|
|
|
1289 |
if (dir.dirList(d, Utils::WString::Null(), f.filename()))
|
| 126 |
cycrow |
1290 |
{
|
|
|
1291 |
for (auto itr2 = d.begin(); itr2 != d.end(); itr2++)
|
|
|
1292 |
{
|
| 196 |
cycrow |
1293 |
Utils::WString ext = CFileIO((*itr2)->str).extension().lower();
|
|
|
1294 |
if (ext == L"xsp" || ext == L"spk")
|
| 126 |
cycrow |
1295 |
fileList.pushBack(dir.file((*itr2)->str));
|
|
|
1296 |
}
|
|
|
1297 |
}
|
|
|
1298 |
}
|
|
|
1299 |
}
|
|
|
1300 |
|
|
|
1301 |
if (fileList.empty())
|
| 298 |
cycrow |
1302 |
wprintf(L"unable to find any packages");
|
| 126 |
cycrow |
1303 |
else
|
|
|
1304 |
{
|
| 197 |
cycrow |
1305 |
Utils::WStringList filedata;
|
| 126 |
cycrow |
1306 |
for (auto itr = fileList.begin(); itr != fileList.end(); itr++)
|
|
|
1307 |
{
|
| 196 |
cycrow |
1308 |
wprintf(L"Reading file: %s\n", (*itr)->str.c_str());
|
| 126 |
cycrow |
1309 |
|
|
|
1310 |
int error = 0;
|
| 321 |
cycrow |
1311 |
CBaseFile *p = cmd.packages().openPackage((*itr)->str.toString(), &error, 0, SPKREAD_NODATA);
|
| 126 |
cycrow |
1312 |
if (!p)
|
|
|
1313 |
{
|
|
|
1314 |
printf("\tERROR!\n");
|
|
|
1315 |
continue;
|
|
|
1316 |
}
|
| 204 |
cycrow |
1317 |
wprintf(L"\tData extracted: %s %s by %s\n", p->name().c_str(), p->version().c_str(), p->author().c_str());
|
| 126 |
cycrow |
1318 |
if (!p->creationDate().empty())
|
| 204 |
cycrow |
1319 |
wprintf(L"\t\tCreated: %s\n", p->creationDate().c_str());
|
| 126 |
cycrow |
1320 |
if(!p->description().empty())
|
| 206 |
cycrow |
1321 |
wprintf(L"\t\t%s\n", p->description().c_str());
|
| 126 |
cycrow |
1322 |
|
|
|
1323 |
filedata.pushBack(CPackages::FormatAvailablePackageData(p));
|
|
|
1324 |
delete p;
|
|
|
1325 |
}
|
|
|
1326 |
|
|
|
1327 |
if (filedata.empty())
|
| 298 |
cycrow |
1328 |
wprintf(L"unable to find any packages");
|
| 126 |
cycrow |
1329 |
else
|
|
|
1330 |
{
|
| 321 |
cycrow |
1331 |
Utils::WString dest = cmd.dirIO().file(L"xpackagedata.dat");
|
| 126 |
cycrow |
1332 |
if (CFileIO(dest).writeFile(&filedata))
|
| 298 |
cycrow |
1333 |
wprintf(L"web update file, xpackagedata.dat, generated");
|
| 126 |
cycrow |
1334 |
else
|
| 298 |
cycrow |
1335 |
wprintf(L"unable to write update file");
|
| 126 |
cycrow |
1336 |
}
|
|
|
1337 |
}
|
|
|
1338 |
}
|
|
|
1339 |
}
|
|
|
1340 |
|
| 196 |
cycrow |
1341 |
void GenerateUpdateFile(const Utils::WString &spkfile)
|
| 1 |
cycrow |
1342 |
{
|
| 182 |
cycrow |
1343 |
if (!CFileIO::Exists(spkfile))
|
| 1 |
cycrow |
1344 |
{
|
| 196 |
cycrow |
1345 |
wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
|
| 1 |
cycrow |
1346 |
return;
|
|
|
1347 |
}
|
|
|
1348 |
|
| 197 |
cycrow |
1349 |
int check = CSpkFile::CheckFile(spkfile);
|
| 1 |
cycrow |
1350 |
if ( check == SPKFILE_MULTI )
|
|
|
1351 |
{
|
| 298 |
cycrow |
1352 |
wprintf(L"Error: Multi-Package files currently not supported\n");
|
| 1 |
cycrow |
1353 |
return;
|
|
|
1354 |
}
|
|
|
1355 |
else if ( check == SPKFILE_OLD )
|
|
|
1356 |
{
|
| 298 |
cycrow |
1357 |
wprintf(L"Error: unable to read old format spk file, try spkconvert first\n");
|
| 1 |
cycrow |
1358 |
return;
|
|
|
1359 |
}
|
|
|
1360 |
else if ( check == SPKFILE_INVALID )
|
|
|
1361 |
{
|
| 196 |
cycrow |
1362 |
wprintf(L"Error: %s doesn't appear to be a valid package file\n", spkfile.c_str());
|
| 1 |
cycrow |
1363 |
return;
|
|
|
1364 |
}
|
|
|
1365 |
|
|
|
1366 |
CPackages p;
|
|
|
1367 |
int error;
|
| 298 |
cycrow |
1368 |
CBaseFile *package = p.openPackage(spkfile, &error, 0, SPKREAD_NODATA);
|
| 1 |
cycrow |
1369 |
if ( !package )
|
|
|
1370 |
{
|
| 196 |
cycrow |
1371 |
wprintf(L"Error: unable to open package file, %s, Error=%d\n", spkfile.c_str(), error);
|
| 1 |
cycrow |
1372 |
return;
|
|
|
1373 |
}
|
|
|
1374 |
|
| 196 |
cycrow |
1375 |
Utils::WString file = package->createUpdateFile(CFileIO(spkfile).dir());
|
| 102 |
cycrow |
1376 |
if ( file.empty() )
|
| 196 |
cycrow |
1377 |
wprintf(L"Error: unable to create update file for: %s, Directory=%s\n", spkfile.c_str(), CFileIO(spkfile).dir().c_str());
|
| 1 |
cycrow |
1378 |
else
|
| 196 |
cycrow |
1379 |
wprintf(L"Update file: %s has been created for package, %s\n", file.c_str(), spkfile.c_str());
|
| 1 |
cycrow |
1380 |
|
|
|
1381 |
delete package;
|
|
|
1382 |
|
|
|
1383 |
}
|
|
|
1384 |
|
| 298 |
cycrow |
1385 |
void GeneratePackagerScript(const Utils::WString &spkfile, Utils::WString toFile, int game)
|
| 1 |
cycrow |
1386 |
{
|
| 126 |
cycrow |
1387 |
if (!CFileIO::Exists(spkfile))
|
| 1 |
cycrow |
1388 |
{
|
| 298 |
cycrow |
1389 |
wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
|
| 1 |
cycrow |
1390 |
return;
|
|
|
1391 |
}
|
|
|
1392 |
|
|
|
1393 |
int check = CSpkFile::CheckFile(spkfile);
|
|
|
1394 |
if ( check == SPKFILE_MULTI )
|
|
|
1395 |
{
|
| 298 |
cycrow |
1396 |
wprintf(L"Error: Cant generate a script from a multi-spk file\n");
|
| 1 |
cycrow |
1397 |
return;
|
|
|
1398 |
}
|
|
|
1399 |
else if ( check == SPKFILE_OLD )
|
|
|
1400 |
{
|
| 298 |
cycrow |
1401 |
wprintf(L"Error: unable to read old format spk file, try spkconvert first\n");
|
| 1 |
cycrow |
1402 |
return;
|
|
|
1403 |
}
|
|
|
1404 |
else if ( check == SPKFILE_INVALID )
|
|
|
1405 |
{
|
| 298 |
cycrow |
1406 |
wprintf(L"Error: %s doesn't appear to be a spk file\n", spkfile.c_str());
|
| 1 |
cycrow |
1407 |
return;
|
|
|
1408 |
}
|
|
|
1409 |
|
|
|
1410 |
CPackages p;
|
| 226 |
cycrow |
1411 |
p.startup(L".", L".", L".");
|
| 1 |
cycrow |
1412 |
int error;
|
| 182 |
cycrow |
1413 |
CBaseFile *package = p.openPackage(spkfile, &error, 0, SPKREAD_NODATA);
|
| 1 |
cycrow |
1414 |
if ( !package )
|
|
|
1415 |
{
|
| 298 |
cycrow |
1416 |
wprintf(L"Error: unable to open package files, %s, Error=%d\n", spkfile.c_str(), error);
|
| 1 |
cycrow |
1417 |
return;
|
|
|
1418 |
}
|
|
|
1419 |
|
| 210 |
cycrow |
1420 |
Utils::WStringList list;
|
| 127 |
cycrow |
1421 |
if ( !p.generatePackagerScript(package, true, &list, game) )
|
| 1 |
cycrow |
1422 |
{
|
| 298 |
cycrow |
1423 |
wprintf(L"Error: Unable to generate packager script\n");
|
| 1 |
cycrow |
1424 |
return;
|
|
|
1425 |
}
|
|
|
1426 |
|
| 298 |
cycrow |
1427 |
if ( toFile.empty() )
|
|
|
1428 |
toFile = CFileIO(spkfile).GetDirIO().file(package->name() + L"_" + package->author() + L".sps");
|
| 1 |
cycrow |
1429 |
|
|
|
1430 |
// save package file
|
| 298 |
cycrow |
1431 |
if ( CFileIO(toFile).writeFile(&list) )
|
|
|
1432 |
wprintf(L"Packager script, %s, has been geenrated\n", toFile.c_str());
|
| 1 |
cycrow |
1433 |
else
|
| 298 |
cycrow |
1434 |
wprintf(L"Error: unable to write packager script, %s\n", toFile.c_str());
|
| 1 |
cycrow |
1435 |
|
|
|
1436 |
delete package;
|
|
|
1437 |
}
|
|
|
1438 |
|
|
|
1439 |
/*
|
|
|
1440 |
Func: LoadPackagerScript
|
|
|
1441 |
Args: String filename - The filename of the packager script to load
|
|
|
1442 |
Desc: Loads the packager scripts and creates a spk/xsp file from it
|
|
|
1443 |
*/
|
| 311 |
cycrow |
1444 |
void LoadPackagerScript(const Utils::CommandLine &cmd, bool verify)
|
| 1 |
cycrow |
1445 |
{
|
| 311 |
cycrow |
1446 |
Utils::WString filename = cmd.arg(1);
|
|
|
1447 |
// check if the file exists in the current directory
|
|
|
1448 |
if (!filename.contains(L":"))
|
|
|
1449 |
filename = CDirIO(g_dir).file(filename);
|
|
|
1450 |
|
|
|
1451 |
if (!CFileIO::Exists(filename))
|
| 1 |
cycrow |
1452 |
{
|
| 197 |
cycrow |
1453 |
wprintf(L"Error: The packager script, %s, does not exist", filename.c_str());
|
| 1 |
cycrow |
1454 |
return;
|
|
|
1455 |
}
|
|
|
1456 |
|
| 197 |
cycrow |
1457 |
Utils::WString myDoc;
|
| 1 |
cycrow |
1458 |
#ifdef _WIN32
|
|
|
1459 |
TCHAR pszPath[MAX_PATH];
|
|
|
1460 |
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
|
|
|
1461 |
{
|
| 311 |
cycrow |
1462 |
myDoc = pszPath;
|
| 1 |
cycrow |
1463 |
}
|
|
|
1464 |
#endif
|
|
|
1465 |
|
|
|
1466 |
if ( verify )
|
| 197 |
cycrow |
1467 |
wprintf(L"Verifying Packager Script: %s\n", filename.c_str());
|
| 1 |
cycrow |
1468 |
|
|
|
1469 |
CPackages p;
|
| 321 |
cycrow |
1470 |
p.startup(L".", cmd.tempDir(), cmd.myDoc());
|
| 197 |
cycrow |
1471 |
Utils::WStringList malformed, unknown;
|
| 1 |
cycrow |
1472 |
|
| 197 |
cycrow |
1473 |
Utils::WString curDir = CFileIO(filename).dir();
|
| 196 |
cycrow |
1474 |
if ( curDir.empty() ) curDir = L"./";
|
| 1 |
cycrow |
1475 |
|
| 197 |
cycrow |
1476 |
Utils::WStringList variables;
|
|
|
1477 |
variables.pushBack(L"$PATH", curDir);
|
| 1 |
cycrow |
1478 |
|
| 311 |
cycrow |
1479 |
CFileProgress info(&p, NULL, "Added File");
|
| 197 |
cycrow |
1480 |
CBaseFile *package = p.loadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables, &info);
|
| 1 |
cycrow |
1481 |
|
| 134 |
cycrow |
1482 |
printf("\n");
|
|
|
1483 |
|
| 1 |
cycrow |
1484 |
if ( verify )
|
|
|
1485 |
{
|
| 131 |
cycrow |
1486 |
if ( !malformed.empty() )
|
| 1 |
cycrow |
1487 |
{
|
| 306 |
cycrow |
1488 |
printf("Malformed Lines (%lu):\n", static_cast<unsigned long>(malformed.size()));
|
| 131 |
cycrow |
1489 |
for(auto itr = malformed.begin(); itr != malformed.end(); itr++)
|
| 197 |
cycrow |
1490 |
wprintf(L"\t(Line %3d) %s\n", (*itr)->data.toInt(), (*itr)->str.c_str());
|
| 1 |
cycrow |
1491 |
}
|
| 131 |
cycrow |
1492 |
if ( !unknown.empty() )
|
| 1 |
cycrow |
1493 |
{
|
| 306 |
cycrow |
1494 |
printf("Unknown Commands (%lu):\n", static_cast<unsigned long>(unknown.size()));
|
| 131 |
cycrow |
1495 |
for (auto itr = unknown.begin(); itr != unknown.end(); itr++)
|
| 197 |
cycrow |
1496 |
wprintf(L"\t* Command: %s = %s\n", (*itr)->str.c_str(), (*itr)->data.c_str());
|
| 1 |
cycrow |
1497 |
}
|
|
|
1498 |
}
|
|
|
1499 |
|
|
|
1500 |
if ( !package )
|
|
|
1501 |
{
|
|
|
1502 |
if ( verify )
|
|
|
1503 |
printf("Error: There are errors in the packager script which prevents it from being created\n");
|
|
|
1504 |
else
|
| 197 |
cycrow |
1505 |
wprintf(L"Error: Unable to create package, from script: %s\n", filename.c_str());
|
| 1 |
cycrow |
1506 |
}
|
|
|
1507 |
else
|
|
|
1508 |
{
|
| 197 |
cycrow |
1509 |
Utils::WString saveto = package->filename();
|
|
|
1510 |
saveto = saveto.findReplace(L"$DEFAULTDIR", curDir + L"/");
|
|
|
1511 |
saveto = saveto.findReplace(L"$PATH", curDir);
|
|
|
1512 |
saveto = saveto.findReplace(L"\\", L"/");
|
|
|
1513 |
saveto = saveto.findReplace(L"//", L"/");
|
|
|
1514 |
if ( !saveto.right(4).Compare(L".spk") && package->GetType() != TYPE_XSP )
|
|
|
1515 |
saveto += L".spk";
|
|
|
1516 |
else if ( !saveto.right(4).Compare(L".xsp") && package->GetType() == TYPE_XSP )
|
|
|
1517 |
saveto += L".xsp";
|
| 196 |
cycrow |
1518 |
wprintf(L"Saving file to: %s\n", CFileIO(saveto).fullFilename().c_str());
|
| 1 |
cycrow |
1519 |
if ( verify )
|
|
|
1520 |
printf("Package can be created from this script\n");
|
|
|
1521 |
else
|
|
|
1522 |
{
|
|
|
1523 |
// write script
|
| 197 |
cycrow |
1524 |
if ( package->writeFile(saveto.toString()) )
|
| 1 |
cycrow |
1525 |
{
|
|
|
1526 |
if ( package->AutoGenerateUpdateFile() )
|
| 134 |
cycrow |
1527 |
package->createUpdateFile(CFileIO(saveto).dir());
|
| 197 |
cycrow |
1528 |
wprintf(L"Package: %s was created\n", saveto.c_str());
|
| 1 |
cycrow |
1529 |
}
|
|
|
1530 |
else
|
|
|
1531 |
printf("Error! There was a problem writing the package\n");
|
|
|
1532 |
}
|
|
|
1533 |
|
| 204 |
cycrow |
1534 |
saveto = package->exportFilename();
|
| 131 |
cycrow |
1535 |
if ( !saveto.empty() ) {
|
| 197 |
cycrow |
1536 |
saveto = saveto.findReplace(L"$DEFAULTDIR", curDir + L"/");
|
|
|
1537 |
saveto = saveto.findReplace(L"$PATH", curDir);
|
|
|
1538 |
saveto = saveto.findReplace(L"\\", L"/");
|
|
|
1539 |
saveto = saveto.findReplace(L"//", L"/");
|
| 196 |
cycrow |
1540 |
wprintf(L"Exporting file to: %s\n", CFileIO(saveto).fullFilename().c_str());
|
| 1 |
cycrow |
1541 |
if ( verify )
|
|
|
1542 |
printf("Package can be exported from this script\n");
|
|
|
1543 |
else
|
|
|
1544 |
{
|
|
|
1545 |
// export
|
| 197 |
cycrow |
1546 |
if ( package->saveToArchive(saveto.toString(), 0, p.GetGameExe())) {
|
| 1 |
cycrow |
1547 |
if ( package->IsAnyGameInPackage() ) {
|
| 197 |
cycrow |
1548 |
for ( int i = 0; i < p.GetGameExe()->numGames(); i++ ) {
|
| 1 |
cycrow |
1549 |
if ( package->IsGameInPackage(i + 1) ) {
|
| 197 |
cycrow |
1550 |
Utils::WString exportFile = CFileIO(saveto).dir() + L"/" + CFileIO(saveto).baseName() + L"_" + CBaseFile::ConvertGameToString(i + 1) + L"." + CFileIO(saveto).extension();
|
| 196 |
cycrow |
1551 |
package->saveToArchive(exportFile.toString(), i + 1, p.GetGameExe());
|
| 1 |
cycrow |
1552 |
}
|
|
|
1553 |
}
|
|
|
1554 |
}
|
| 197 |
cycrow |
1555 |
wprintf(L"Package: %s was exported\n", saveto.c_str());
|
| 1 |
cycrow |
1556 |
}
|
|
|
1557 |
else
|
|
|
1558 |
printf("Error! There was a problem exporting the package\n");
|
|
|
1559 |
}
|
|
|
1560 |
}
|
|
|
1561 |
}
|
|
|
1562 |
}
|
|
|
1563 |
|
| 311 |
cycrow |
1564 |
Utils::WString GetFileTypes()
|
|
|
1565 |
{
|
|
|
1566 |
Utils::WString fileTypes;
|
|
|
1567 |
for (int i = 0; i < FILETYPE_MAX; i++)
|
|
|
1568 |
{
|
|
|
1569 |
Utils::WString sT = GetFileTypeString(i);
|
|
|
1570 |
if (!sT.empty())
|
|
|
1571 |
{
|
|
|
1572 |
if (fileTypes.empty())
|
|
|
1573 |
fileTypes = sT;
|
|
|
1574 |
else
|
|
|
1575 |
{
|
|
|
1576 |
fileTypes += L", ";
|
|
|
1577 |
fileTypes += sT;
|
|
|
1578 |
}
|
|
|
1579 |
}
|
|
|
1580 |
}
|
|
|
1581 |
return fileTypes;
|
|
|
1582 |
}
|
|
|
1583 |
|
| 1 |
cycrow |
1584 |
/*
|
|
|
1585 |
Main entry point to program
|
|
|
1586 |
*/
|
|
|
1587 |
int main ( int argc, char **argv )
|
|
|
1588 |
{
|
|
|
1589 |
// display program header to command prompt
|
| 311 |
cycrow |
1590 |
printf ( "\nSPKTool V1.51 (SPK File Version %.2f) 17/05/2025 Created by Cycrow\n\n", (float)FILEVERSION );
|
| 1 |
cycrow |
1591 |
|
| 307 |
cycrow |
1592 |
Utils::CommandLine cmd(argc, argv);
|
|
|
1593 |
g_dir = cmd.cmdDir();
|
| 1 |
cycrow |
1594 |
g_read = false;
|
|
|
1595 |
|
|
|
1596 |
// not enough arguments, display the syntax and exit
|
| 311 |
cycrow |
1597 |
if (cmd.argCount() < 1)
|
| 1 |
cycrow |
1598 |
{
|
| 307 |
cycrow |
1599 |
PrintSyntax(cmd.cmdName());
|
| 1 |
cycrow |
1600 |
exit ( 1 );
|
|
|
1601 |
}
|
|
|
1602 |
|
|
|
1603 |
// get the command flag
|
| 311 |
cycrow |
1604 |
Utils::WString command(cmd.arg(0));
|
| 1 |
cycrow |
1605 |
|
|
|
1606 |
// display the contents of the spk file
|
| 307 |
cycrow |
1607 |
if ( command == L"-v" || command == L"-view" || command == L"-version")
|
| 1 |
cycrow |
1608 |
{
|
|
|
1609 |
if ( argc < 3 )
|
| 307 |
cycrow |
1610 |
wprintf(L"Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.cmdName().c_str());
|
| 1 |
cycrow |
1611 |
else
|
| 321 |
cycrow |
1612 |
DisplayVersion(cmd);
|
| 1 |
cycrow |
1613 |
}
|
|
|
1614 |
|
|
|
1615 |
// creates a new spk file
|
| 307 |
cycrow |
1616 |
else if ( command == L"-c" || command == L"-create" )
|
| 1 |
cycrow |
1617 |
{
|
|
|
1618 |
if ( argc < 3 )
|
| 307 |
cycrow |
1619 |
wprintf(L"Syntax:\n\t%s -c <spkfile>\n\t%s -create <spkfile>\n\t\tThis will create a new SPK file and allow you to set some basic settings for the file\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1620 |
else
|
|
|
1621 |
CreateFile ( argv[2] );
|
|
|
1622 |
}
|
|
|
1623 |
|
|
|
1624 |
// appends a file onto the spk archive
|
| 307 |
cycrow |
1625 |
else if ( command == L"-a" || command == L"-append" )
|
| 1 |
cycrow |
1626 |
{
|
|
|
1627 |
if ( argc < 4 )
|
| 311 |
cycrow |
1628 |
wprintf(L"Syntax:\n\t%s -a <spkfile> <type> <filename>\n\t%s -append <spkfile> <type> <filename>\n\t\tThis will append the file into the archive and compress it according to the files default compression\n\t<type> = %s\n", cmd.cmdName().c_str(), cmd.cmdName().c_str(), GetFileTypes().c_str() );
|
| 1 |
cycrow |
1629 |
else
|
|
|
1630 |
{
|
| 298 |
cycrow |
1631 |
Utils::WString arg4;
|
| 1 |
cycrow |
1632 |
if ( argc > 4 )
|
|
|
1633 |
arg4 = argv[4];
|
|
|
1634 |
AppendFile ( argv[2], argv[3], arg4 );
|
|
|
1635 |
}
|
|
|
1636 |
}
|
|
|
1637 |
|
|
|
1638 |
// removes a file from the spk archive
|
| 307 |
cycrow |
1639 |
else if ( command == L"-r" || command == L"-remove" || command == L"-removespk" )
|
| 1 |
cycrow |
1640 |
{
|
|
|
1641 |
if ( argc < 4 )
|
|
|
1642 |
{
|
| 311 |
cycrow |
1643 |
wprintf(L"Syntax:\n\t%s -r <spkfile> <type> <filename>\n\t%s -remove <spkfile> <type> <filename\n\t\tThis will remove a file from the archive\n\t<type> = %s\n", cmd.cmdName().c_str(), cmd.cmdName().c_str(), GetFileTypes().c_str() );
|
| 307 |
cycrow |
1644 |
wprintf(L"\t%s -r <multispkfile> <filename>\n\t%s -removespk <multispkfile> <filename>\n\t\tThis will remove a spk file from the Multi-SPK package\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1645 |
}
|
|
|
1646 |
else
|
|
|
1647 |
{
|
| 298 |
cycrow |
1648 |
Utils::WString arg4;
|
| 1 |
cycrow |
1649 |
if ( argc > 4 )
|
|
|
1650 |
arg4 = argv[4];
|
|
|
1651 |
RemoveFile ( argv[2], argv[3], arg4 );
|
|
|
1652 |
}
|
|
|
1653 |
}
|
|
|
1654 |
|
|
|
1655 |
// extracts a file from a spk file
|
| 307 |
cycrow |
1656 |
else if ( command == L"-extractspk" )
|
| 1 |
cycrow |
1657 |
{
|
|
|
1658 |
if ( argc < 4 )
|
| 307 |
cycrow |
1659 |
wprintf(L"Syntax:\n\t%s -extractspk <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1660 |
else
|
|
|
1661 |
{
|
| 298 |
cycrow |
1662 |
Utils::WString arg4;
|
| 1 |
cycrow |
1663 |
if ( argc > 4 )
|
|
|
1664 |
arg4 = argv[3];
|
| 298 |
cycrow |
1665 |
ExtractFile(argv[2], argv[3], arg4, Utils::WString::Null());
|
| 1 |
cycrow |
1666 |
}
|
|
|
1667 |
}
|
| 307 |
cycrow |
1668 |
else if ( command == L"-x" || command == L"-extract")
|
| 1 |
cycrow |
1669 |
{
|
|
|
1670 |
if ( argc < 4 )
|
|
|
1671 |
{
|
| 311 |
cycrow |
1672 |
wprintf(L"Syntax:\n\t%s -x <spkfile> <type> <filename> [destination]\n\tThis will extract a file from the package and save it to the corect path in <directory>\n\t<type> = %s\n", cmd.cmdName().c_str(), GetFileTypes().c_str() );
|
| 307 |
cycrow |
1673 |
wprintf(L"\t%s -x <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1674 |
}
|
|
|
1675 |
else
|
|
|
1676 |
{
|
| 298 |
cycrow |
1677 |
Utils::WString arg5, arg4;
|
| 1 |
cycrow |
1678 |
if ( argc > 5 )
|
|
|
1679 |
arg5 = argv[5];
|
|
|
1680 |
if ( argc > 4 )
|
|
|
1681 |
arg4 = argv[4];
|
| 134 |
cycrow |
1682 |
ExtractFile(argv[2], argv[3], arg4, arg5);
|
| 1 |
cycrow |
1683 |
}
|
|
|
1684 |
}
|
|
|
1685 |
|
|
|
1686 |
// extracts all the files from an archive
|
| 307 |
cycrow |
1687 |
else if ( command == L"-e" || command == L"-extractall" )
|
| 1 |
cycrow |
1688 |
{
|
|
|
1689 |
if ( argc < 3 )
|
| 315 |
cycrow |
1690 |
wprintf(L"Syntax:\n\t%s -e <spkfile> [destination]\n\t-extractall --game:<game> <spkfile> [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.cmdName().c_str() );
|
| 1 |
cycrow |
1691 |
else
|
| 315 |
cycrow |
1692 |
ExtractFiles(cmd);
|
| 1 |
cycrow |
1693 |
}
|
|
|
1694 |
|
|
|
1695 |
// creates a multispk archive
|
| 307 |
cycrow |
1696 |
else if ( command == L"-n" || command == L"-createmulti" )
|
| 1 |
cycrow |
1697 |
{
|
|
|
1698 |
if ( argc < 3 )
|
| 307 |
cycrow |
1699 |
wprintf(L"Syntax:\n\t%s -n <multispkfile>\n\t%s -createmulti <multispkfile>\n\t\tThis will create a multispk file and allow you to add spk files to it\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1700 |
else
|
|
|
1701 |
CreateMultiFile ( argv[2] );
|
|
|
1702 |
}
|
|
|
1703 |
|
|
|
1704 |
// merges 2 multi-spk archives together, or appends a single spk file into a multi-spk file
|
| 307 |
cycrow |
1705 |
else if ( command == L"-m" || command == L"-mergemulti" )
|
| 1 |
cycrow |
1706 |
{
|
|
|
1707 |
if ( argc < 4 )
|
| 307 |
cycrow |
1708 |
wprintf(L"Syntax:\n\t%s -m <spkfile1> <spkfile2>\n\t%s -mergemulti <spkfile1> <spkfile2>\n\t\tThis will add spkfile2 into spkfile1, if spkfile1 is a normal SPK file, it will be saved into a Multi-Spk file\nspkfile2 can also be a Multi-Spk file, all files within it will be added\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1709 |
else
|
|
|
1710 |
AppendMultiFile ( argv[2], argv[3] );
|
|
|
1711 |
}
|
|
|
1712 |
|
|
|
1713 |
// splits the multi-spk file, exracts all spk files
|
| 307 |
cycrow |
1714 |
else if ( command == L"-s" || command == L"-splitmulti" )
|
| 1 |
cycrow |
1715 |
{
|
|
|
1716 |
if ( argc < 3 )
|
| 307 |
cycrow |
1717 |
wprintf(L"Syntax: %s -s <multispkfile> [destination]\n\tSplits the Multi-SPK file and saves each spk file to the destiantion directory\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1718 |
else
|
|
|
1719 |
{
|
| 298 |
cycrow |
1720 |
Utils::WString arg3;
|
| 1 |
cycrow |
1721 |
if ( argc > 3 )
|
|
|
1722 |
arg3 = argv[3];
|
|
|
1723 |
SplitMulti ( argv[2], arg3 );
|
|
|
1724 |
}
|
|
|
1725 |
}
|
|
|
1726 |
|
| 307 |
cycrow |
1727 |
else if ( command == L"-set" )
|
| 1 |
cycrow |
1728 |
{
|
|
|
1729 |
if ( argc < 4 )
|
| 307 |
cycrow |
1730 |
wprintf(L"Syntax: %s -set <spkfile> <setting> [values]\n\tSets various settings in the package\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1731 |
else
|
| 307 |
cycrow |
1732 |
Settings(cmd);
|
| 1 |
cycrow |
1733 |
}
|
| 307 |
cycrow |
1734 |
else if ( command == L"-setrating" )
|
| 1 |
cycrow |
1735 |
{
|
|
|
1736 |
if ( argc < 6 )
|
| 307 |
cycrow |
1737 |
wprintf(L"Syntax: %s -setrating <spkfile> <easeofuse> <gamechanging> <recommended>\n\tSets the rating of the spk package\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1738 |
else
|
| 298 |
cycrow |
1739 |
SetRating(argv[2], Utils::WString(argv[3]).toInt(), Utils::WString(argv[4]).toInt(), Utils::WString(argv[5]).toInt());
|
| 1 |
cycrow |
1740 |
}
|
| 307 |
cycrow |
1741 |
else if ( command == L"-convertxsp" || command == L"-convertxspwizard" )
|
| 1 |
cycrow |
1742 |
{
|
|
|
1743 |
if ( argc < 3 )
|
| 307 |
cycrow |
1744 |
wprintf(L"Syntax: %s %s <xspfile> [newxspfile]\n\tConverts an old format xsp file to work with the new format\n", cmd.cmdName().c_str(), command.c_str());
|
| 1 |
cycrow |
1745 |
else
|
|
|
1746 |
{
|
| 298 |
cycrow |
1747 |
Utils::WString arg3;
|
| 1 |
cycrow |
1748 |
if ( argc > 3 )
|
|
|
1749 |
arg3 = argv[3];
|
| 307 |
cycrow |
1750 |
ConvertXsp(Utils::WString::FromString(argv[2]), arg3, (command == L"-convertxspwizard") ? true : false);
|
| 1 |
cycrow |
1751 |
}
|
|
|
1752 |
}
|
| 307 |
cycrow |
1753 |
else if ( command == L"-createscript" )
|
| 1 |
cycrow |
1754 |
{
|
| 311 |
cycrow |
1755 |
if (cmd.argCount() < 2)
|
| 307 |
cycrow |
1756 |
wprintf(L"Syntax:\n\t%s -createscript <packagerscript>\n\t\tThis will create a spk/xsp file from a packager script\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1757 |
else
|
| 311 |
cycrow |
1758 |
LoadPackagerScript(cmd, false);
|
| 1 |
cycrow |
1759 |
}
|
| 307 |
cycrow |
1760 |
else if ( command == L"-generatescript" )
|
| 1 |
cycrow |
1761 |
{
|
| 311 |
cycrow |
1762 |
if (cmd.argCount() < 2)
|
| 307 |
cycrow |
1763 |
wprintf(L"Syntax:\n\t%s -generatescript <package> [packagerscript]\n\t\tThis will generate a packager script file from a spk/xsp file.\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1764 |
else
|
|
|
1765 |
{
|
| 311 |
cycrow |
1766 |
if (cmd.argCount() < 3)
|
| 126 |
cycrow |
1767 |
GeneratePackagerScript ( argv[2], "", 0);
|
| 1 |
cycrow |
1768 |
else
|
| 126 |
cycrow |
1769 |
GeneratePackagerScript ( argv[2], argv[3], 0);
|
| 1 |
cycrow |
1770 |
}
|
|
|
1771 |
}
|
| 307 |
cycrow |
1772 |
else if ( command == L"-verifyscript" )
|
| 1 |
cycrow |
1773 |
{
|
| 311 |
cycrow |
1774 |
if (cmd.argCount() < 2)
|
| 307 |
cycrow |
1775 |
wprintf(L"Syntax:\n\t%s -verifyscript <packagerscript>\n\t\tThis will read a packager script and check its correct without creating the resulting spk/xsp file\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1776 |
else
|
| 311 |
cycrow |
1777 |
LoadPackagerScript(cmd, true);
|
| 1 |
cycrow |
1778 |
}
|
| 307 |
cycrow |
1779 |
else if ( command == L"-extractship" )
|
| 1 |
cycrow |
1780 |
{
|
|
|
1781 |
if ( argc < 4 )
|
| 307 |
cycrow |
1782 |
wprintf(L"Syntax:\n\t%s -extractship <modfile> <xspfile> [shipid]\n\t\tThis will create an xsp ship file by extracting from a mod file\n", cmd.cmdName().c_str() );
|
| 1 |
cycrow |
1783 |
else
|
|
|
1784 |
{
|
|
|
1785 |
if ( argc < 5 )
|
| 197 |
cycrow |
1786 |
ExtractShip ( argv[2], argv[3], L"" );
|
| 1 |
cycrow |
1787 |
else
|
|
|
1788 |
ExtractShip ( argv[2], argv[3], argv[4] );
|
|
|
1789 |
}
|
|
|
1790 |
}
|
| 307 |
cycrow |
1791 |
else if (command == L"-generateupdatefile")
|
| 1 |
cycrow |
1792 |
{
|
| 197 |
cycrow |
1793 |
if (argc < 3)
|
| 307 |
cycrow |
1794 |
wprintf(L"Syntax:\n\t%s -generateupdatefile <package>\n\t\tThis will generate the update file to allow auto updates for a package\n", cmd.cmdName().c_str());
|
| 197 |
cycrow |
1795 |
else
|
|
|
1796 |
GenerateUpdateFile(argv[2]);
|
| 126 |
cycrow |
1797 |
}
|
| 307 |
cycrow |
1798 |
else if (command == L"-packagelist")
|
| 126 |
cycrow |
1799 |
{
|
|
|
1800 |
if (argc < 3)
|
| 307 |
cycrow |
1801 |
wprintf(L"Syntax:\n\t%s -packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n", cmd.cmdName().c_str());
|
| 1 |
cycrow |
1802 |
else
|
| 321 |
cycrow |
1803 |
GenerateUpdateList(cmd);
|
| 1 |
cycrow |
1804 |
}
|
|
|
1805 |
|
|
|
1806 |
// not a valid switch, display syntax
|
|
|
1807 |
else
|
| 307 |
cycrow |
1808 |
PrintSyntax(cmd.cmdName());
|
| 1 |
cycrow |
1809 |
|
|
|
1810 |
#ifdef _DEBUG
|
|
|
1811 |
char pause;
|
|
|
1812 |
scanf ( "%s", &pause );
|
|
|
1813 |
#endif
|
|
|
1814 |
|
|
|
1815 |
return 0;
|
|
|
1816 |
}
|