| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
namespace SPK {
|
3 |
namespace SPK {
|
| 4 |
s_int GetAutomaticFiletype(const Utils::String &file, Utils::String *extradir, bool bUseSpecial)
|
4 |
s_int GetAutomaticFiletype(const Utils::String &file, Utils::String *extradir, bool bUseSpecial)
|
| 5 |
{
|
5 |
{
|
| 6 |
CFileIO File(file);
|
6 |
CFileIO File(file);
|
| 7 |
Utils::String dir = File.GetDirIO().topDir();
|
7 |
Utils::WString dir = File.GetDirIO().topDir();
|
| 8 |
|
8 |
|
| 9 |
Utils::String basename = File.baseName();
|
9 |
Utils::WString basename = File.baseName();
|
| 10 |
// could be a script, text file or map
|
10 |
// could be a script, text file or map
|
| 11 |
s_int type = -1;
|
11 |
s_int type = -1;
|
| 12 |
if ( dir.Compare("types") || dir.Compare("mov") || dir.Compare("s") )
|
12 |
if ( dir.Compare(L"types") || dir.Compare(L"mov") || dir.Compare(L"s") )
|
| 13 |
{
|
13 |
{
|
| 14 |
type = FILETYPE_EXTRA;
|
14 |
type = FILETYPE_EXTRA;
|
| 15 |
if ( extradir )
|
15 |
if ( extradir )
|
| 16 |
*extradir = dir;
|
16 |
*extradir = dir.toString();
|
| 17 |
}
|
17 |
}
|
| 18 |
else if ( File.isFileExtension("xml") || File.isFileExtension("pck") )
|
18 |
else if ( File.isFileExtension(L"xml") || File.isFileExtension(L"pck") )
|
| 19 |
{
|
19 |
{
|
| 20 |
// TC text file
|
20 |
// TC text file
|
| 21 |
type = FILETYPE_SCRIPT;
|
21 |
type = FILETYPE_SCRIPT;
|
| 22 |
if ( File.filename().isin("-L") && ((int)File.filename().left(4)) )
|
22 |
if ( File.filename().contains(L"-L") && ((int)File.filename().left(4)) )
|
| 23 |
type = FILETYPE_TEXT;
|
23 |
type = FILETYPE_TEXT;
|
| 24 |
if ( File.baseName().Compare("conversations") )
|
24 |
if ( File.baseName().Compare(L"conversations") )
|
| 25 |
type = FILETYPE_TEXT;
|
25 |
type = FILETYPE_TEXT;
|
| 26 |
// X2/X3 text file
|
26 |
// X2/X3 text file
|
| 27 |
else if ( basename.length() >= 5 && basename.length() <= 8 && ((int)File.baseName()) )
|
27 |
else if ( basename.length() >= 5 && basename.length() <= 8 && ((int)File.baseName()) )
|
| 28 |
type = FILETYPE_TEXT;
|
28 |
type = FILETYPE_TEXT;
|
| 29 |
else if ( dir.Compare("maps") )
|
29 |
else if ( dir.Compare(L"maps") )
|
| 30 |
type = FILETYPE_MAP;
|
30 |
type = FILETYPE_MAP;
|
| 31 |
else if ( dir.Compare("t") )
|
31 |
else if ( dir.Compare(L"t") )
|
| 32 |
type = FILETYPE_TEXT;
|
32 |
type = FILETYPE_TEXT;
|
| 33 |
else if ( (bUseSpecial) && (dir.Compare("scripts") && basename.contains("uninstall")) )
|
33 |
else if ( (bUseSpecial) && (dir.Compare(L"scripts") && basename.contains(L"uninstall")) )
|
| 34 |
type = FILETYPE_SCRIPT_UNINSTALL;
|
34 |
type = FILETYPE_SCRIPT_UNINSTALL;
|
| 35 |
else if ( dir.Compare("uninstall") || basename.contains("uninstall") )
|
35 |
else if ( dir.Compare(L"uninstall") || basename.contains(L"uninstall") )
|
| 36 |
type = FILETYPE_UNINSTALL;
|
36 |
type = FILETYPE_UNINSTALL;
|
| 37 |
else if ( dir.isin("uninstall") )
|
37 |
else if ( dir.isin(L"uninstall") )
|
| 38 |
type = FILETYPE_UNINSTALL;
|
38 |
type = FILETYPE_UNINSTALL;
|
| 39 |
else if ( dir.Compare("director") )
|
39 |
else if ( dir.Compare(L"director") )
|
| 40 |
type = FILETYPE_MISSION;
|
40 |
type = FILETYPE_MISSION;
|
| 41 |
}
|
41 |
}
|
| 42 |
// could be a model file or scene file
|
42 |
// could be a model file or scene file
|
| 43 |
else if ( File.isFileExtension("pbd") || File.isFileExtension("bod") )
|
43 |
else if ( File.isFileExtension(L"pbd") || File.isFileExtension(L"bod") )
|
| 44 |
{
|
44 |
{
|
| 45 |
if ( dir.isin("cockpit") || basename.contains("cockpit") )
|
45 |
if ( dir.isin(L"cockpit") || basename.contains(L"cockpit") )
|
| 46 |
type = FILETYPE_COCKPITSCENE;
|
46 |
type = FILETYPE_COCKPITSCENE;
|
| 47 |
else
|
47 |
else
|
| 48 |
type = FILETYPE_SHIPSCENE;
|
48 |
type = FILETYPE_SHIPSCENE;
|
| 49 |
}
|
49 |
}
|
| 50 |
// can only be a model
|
50 |
// can only be a model
|
| 51 |
else if ( File.isFileExtension("pbb") || File.isFileExtension("bob") )
|
51 |
else if ( File.isFileExtension(L"pbb") || File.isFileExtension(L"bob") )
|
| 52 |
type = FILETYPE_SHIPMODEL;
|
52 |
type = FILETYPE_SHIPMODEL;
|
| 53 |
// texture file
|
53 |
// texture file
|
| 54 |
else if ( File.isFileExtension("dds") )
|
54 |
else if ( File.isFileExtension(L"dds") )
|
| 55 |
type = FILETYPE_SHIPOTHER;
|
55 |
type = FILETYPE_SHIPOTHER;
|
| 56 |
else if ( File.isFileExtension("txt") || dir.Compare("readme") )
|
56 |
else if ( File.isFileExtension(L"txt") || dir.Compare(L"readme") )
|
| 57 |
type = FILETYPE_README;
|
57 |
type = FILETYPE_README;
|
| 58 |
else if ( File.isFileExtension("cat") || File.isFileExtension("dat") )
|
58 |
else if ( File.isFileExtension(L"cat") || File.isFileExtension(L"dat") )
|
| 59 |
type = FILETYPE_MOD;
|
59 |
type = FILETYPE_MOD;
|
| 60 |
else if ( File.isFileExtension("mp3") )
|
60 |
else if ( File.isFileExtension(L"mp3") )
|
| 61 |
type = FILETYPE_SOUND;
|
61 |
type = FILETYPE_SOUND;
|
| 62 |
else if ( dir.Compare("loadscr") )
|
62 |
else if ( dir.Compare(L"loadscr") )
|
| 63 |
type = FILETYPE_SCREEN;
|
63 |
type = FILETYPE_SCREEN;
|
| 64 |
else if ( dir.Compare("graphics") )
|
64 |
else if ( dir.Compare(L"graphics") )
|
| 65 |
type = FILETYPE_ADVERT;
|
65 |
type = FILETYPE_ADVERT;
|
| 66 |
else if ( File.isFileExtension("jpg") || File.isFileExtension("bmp") )
|
66 |
else if ( File.isFileExtension(L"jpg") || File.isFileExtension(L"bmp") )
|
| 67 |
type = FILETYPE_SCREEN;
|
67 |
type = FILETYPE_SCREEN;
|
| 68 |
else if ( File.isFileExtension("gif") )
|
68 |
else if ( File.isFileExtension(L"gif") )
|
| 69 |
type = FILETYPE_ADVERT;
|
69 |
type = FILETYPE_ADVERT;
|
| 70 |
|
70 |
|
| 71 |
return type;
|
71 |
return type;
|
| 72 |
}
|
72 |
}
|
| 73 |
|
73 |
|