|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | + |
| 7 | +namespace HPIZArchiver |
| 8 | +{ |
| 9 | + static class FolderExtension |
| 10 | + { |
| 11 | + static readonly Dictionary<string, string[]> folderExtensionPairs = new Dictionary<string, string[]>() |
| 12 | + { |
| 13 | + { @"ae", new string[] { "txt" } }, |
| 14 | + { @"ai", new string[] { "txt" } }, |
| 15 | + { @"anim3d", new string[] { "bos" } }, |
| 16 | + { @"anims", new string[] { "gaf" } }, |
| 17 | + { @"bitmaps", new string[] { "pcx" } }, |
| 18 | + { @"bitmaps\glamour", new string[] { "pcx" } }, |
| 19 | + { @"camps", new string[] { "tdf" } }, |
| 20 | + { @"camps\briefs", new string[] { "txt", "wav" } }, |
| 21 | + { @"camps\briefs-french", new string[] { "txt", "wav" } }, |
| 22 | + { @"camps\briefs-german", new string[] { "txt", "wav" } }, |
| 23 | + { @"camps\briefs-italian", new string[] { "txt", "wav" } }, |
| 24 | + { @"camps\briefs-spanish", new string[] { "txt", "wav" } }, |
| 25 | + { @"camps\useonly", new string[] { "tdf" } }, |
| 26 | + { @"download", new string[] { "tdf" } }, |
| 27 | + { @"features", new string[] { "tdf" } }, |
| 28 | + { @"fonts", new string[] { "fnt" } }, |
| 29 | + { @"gamedata", new string[] { "tdf" } }, |
| 30 | + { @"gamedate", new string[] { "tdf" } }, |
| 31 | + { @"guie", new string[] { "gui" } }, |
| 32 | + { @"guis", new string[] { "gui" } }, |
| 33 | + { @"maps", new string[] { "ota", "tnt" } }, |
| 34 | + { @"objects3d", new string[] { "3do" } }, |
| 35 | + { @"palettes", new string[] { "pal", "alp", "lht", "shd" } }, |
| 36 | + { @"scripts", new string[] { "bos", "cob" } }, |
| 37 | + { @"sections", new string[] { "sct" } }, |
| 38 | + { @"sounds", new string[] { "wav" } }, |
| 39 | + { @"textures", new string[] { "gaf" } }, |
| 40 | + { @"unitpice", new string[] { "pcx" } }, |
| 41 | + { @"unitpics", new string[] { "pcx" } }, |
| 42 | + { @"units", new string[] { "fbi" } }, |
| 43 | + { @"unitse", new string[] { "fbi" } }, |
| 44 | + { @"weapone", new string[] { "tdf" } }, |
| 45 | + { @"weapons", new string[] { "tdf" } } |
| 46 | + }; |
| 47 | + |
| 48 | + public static bool CheckKnow(string path) |
| 49 | + { |
| 50 | + path = path.ToLower(); |
| 51 | + foreach (var folder in folderExtensionPairs.Keys) |
| 52 | + if(path.StartsWith(folder,StringComparison.OrdinalIgnoreCase)) |
| 53 | + switch (path.Replace(folder, string.Empty).Split('\\').Length) |
| 54 | + { |
| 55 | + case 4: |
| 56 | + if (folder == "sections") goto case 2; |
| 57 | + break; |
| 58 | + case 3: |
| 59 | + if (folder == "features") goto case 2; |
| 60 | + break; |
| 61 | + case 2: |
| 62 | + foreach (var extension in folderExtensionPairs[folder]) |
| 63 | + if (path.EndsWith("." + extension, StringComparison.OrdinalIgnoreCase)) |
| 64 | + return true; |
| 65 | + break; |
| 66 | + } |
| 67 | + return false; |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments