Exemple #1
0
        protected override CASCFolder CreateStorageTree()
        {
            var root = new CASCFolder("root");

            // Reset counts
            CountSelect = 0;
            UnknownFiles.Clear();

            // Create new tree based on specified locale
            foreach (var rootEntry in RootData)
            {
                var rootInfosLocale = rootEntry.Value.Where(re => (re.LocaleFlags & Locale) != 0);

                if (rootInfosLocale.Count() > 1)
                {
                    var rootInfosLocaleAndContent = rootInfosLocale.Where(re => (re.ContentFlags == Content));

                    if (rootInfosLocaleAndContent.Any())
                    {
                        rootInfosLocale = rootInfosLocaleAndContent;
                    }
                }

                if (!rootInfosLocale.Any())
                {
                    continue;
                }

                string filename;

                if (!CASCFile.Files.TryGetValue(rootEntry.Key, out CASCFile file))
                {
                    filename = "unknown\\" + rootEntry.Key.ToString("X16") + "_" + GetFileDataIdByHash(rootEntry.Key);

                    UnknownFiles.Add(rootEntry.Key);
                }
                else
                {
                    filename = file.FullName;
                }

                CreateSubTree(root, rootEntry.Key, filename);
                CountSelect++;
            }

            return(root);
        }
Exemple #2
0
        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)
                    {
                        if (!CASCFile.Files.ContainsKey(filehash))
                        {
                            entry = new CASCFile(filehash, file);
                            CASCFile.Files[filehash] = (CASCFile)entry;
                        }
                        else
                        {
                            entry = CASCFile.Files[filehash];
                        }
                    }
                    else
                    {
                        entry = new CASCFolder(entryName);
                    }

                    folder.Entries[entryName] = entry;
                }

                folder = entry as CASCFolder;
            }
        }