private static void Explore(CASCFolder folder, string findFile, SearchType type, List<CASCFile> found) { foreach (KeyValuePair<string, ICASCEntry> node in folder.Entries) { ICASCEntry entry = node.Value; if (entry is CASCFolder) { Explore((CASCFolder)entry, findFile, type, found); } else if (entry is CASCFile) { CASCFile file = (CASCFile)entry; string fileName = file.FullName.ToLower(); if (type == SearchType.COMPLETE && fileName.Equals(fileName)) { found.Add(file); break; } if (type == SearchType.STARTS_WITH && fileName.StartsWith(findFile)) { found.Add(file); continue; } if (type == SearchType.ENDS_WITH && fileName.EndsWith(findFile)) { found.Add(file); continue; } } } }
public void Clear() { RootData.Clear(); RootData = null; FileDataStore.Clear(); FileDataStore = null; FileDataStoreReverse.Clear(); FileDataStoreReverse = null; UnknownFiles.Clear(); UnknownFiles = null; Root?.Entries.Clear(); Root = null; CASCFile.FileNames.Clear(); }
protected CASCFolder CreateStorageTree() { var root = new CASCFolder("root"); CountSelect = 0; UnknownFiles.Clear(); // Create new tree based on specified locale foreach (var rootEntry in RootData) { var rootLocale = rootEntry.Value.Where(re => (re.LocaleFlags & Locale) != 0); if (rootLocale.Count() > 1) { var rootLocaleContent = rootLocale.Where(re => (re.ContentFlags == Content)); if (rootLocaleContent.Any()) { rootLocale = rootLocaleContent; } } if (!rootLocale.Any()) { continue; } string file; if (!CASCFile.FileNames.TryGetValue(rootEntry.Key, out file)) { file = "unknown\\" + rootEntry.Key.ToString("X16") + "_" + GetFileDataIdByHash(rootEntry.Key); UnknownFiles[rootEntry.Key] = true; } CreateSubTree(root, rootEntry.Key, file); CountSelect++; } Log.Write("CASC: {0} file names missing for {1}", CountUnknown, Locale); return(root); }
protected void CreateSubTree(CASCFolder root, ulong filehash, string file) { string[] parts = file.Split(PathDelimiters); CASCFolder folder = root; for (int i = 0; i < parts.Length; ++i) { bool isFile = (i == parts.Length - 1); string entryName = parts[i]; ICASCEntry entry = folder.GetEntry(entryName); if (entry == null) { if (isFile) { entry = new CASCFile(filehash); CASCFile.FileNames[filehash] = file; } else { entry = new CASCFolder(entryName); } folder.Entries[entryName] = entry; } folder = entry as CASCFolder; } }
protected CASCFolder CreateStorageTree() { var root = new CASCFolder("root"); CountSelect = 0; UnknownFiles.Clear(); // Create new tree based on specified locale foreach (var rootEntry in RootData) { var rootLocale = rootEntry.Value.Where(re => (re.LocaleFlags & Locale) != 0); if (rootLocale.Count() > 1) { var rootLocaleContent = rootLocale.Where(re => (re.ContentFlags == Content)); if (rootLocaleContent.Any()) rootLocale = rootLocaleContent; } if (!rootLocale.Any()) continue; string file; if (!CASCFile.FileNames.TryGetValue(rootEntry.Key, out file)) { file = "unknown\\" + rootEntry.Key.ToString("X16") + "_" + GetFileDataIdByHash(rootEntry.Key); UnknownFiles[rootEntry.Key] = true; } CreateSubTree(root, rootEntry.Key, file); CountSelect++; } Log.Write("CASC: {0} file names missing for {1}", CountUnknown, Locale); return root; }
public CASCFolder SetFlags(LocaleFlags locale, ContentFlags content, bool createTree = true) { Locale = locale; Content = content; if (createTree) Root = CreateStorageTree(); return Root; }
private void Explore(CASCFolder folder) { foreach (KeyValuePair<string, ICASCEntry> node in folder.Entries) { ICASCEntry entry = node.Value; if (entry is CASCFolder) { Explore((CASCFolder)entry); } else if (entry is CASCFile) { CASCFile file = (CASCFile)entry; // Check we have a valid extension. if (!IsValidExtension(file)) continue; // Ensure the file matches the filter. if (!MatchesFilter(file.FullName)) continue; EventManager.Trigger_FileExploreHit(id, file); } Thread.Sleep(2); } }