public BundleList ReadBundleList(string listName) { List <SuperBundle> listOfBundles = new List <SuperBundle>(); string[] compare = new string[] { "bundles", "chunks", "ebx", "res", "chunkMeta", "dbx" }; if (!compare.Contains(listName)) { throw new InvalidDataException("Unknown list type."); } int limit = Read7BitEncodedInt(); long startPosition = BaseStream.Position; while (BaseStream.Position < startPosition + limit) { SuperBundle currentBundle = ReadTableOfContentsPayload(); if (currentBundle != null) { listOfBundles.Add(currentBundle); } } BundleList bundleList = new BundleList(); bundleList.Name = listName; bundleList.Bundles = listOfBundles; bundleList.Limit = limit; return(bundleList); }
public void Write(BundleList bundleList) { if (bundleList == null) { return; } Write(bundleList.Opcode); WriteNullTerminatedString(bundleList.Name); Write7BitEncodedInt(bundleList.Limit); foreach (SuperBundle bundle in bundleList.Bundles) { Write(bundle); } Write((byte)0); }
public void ResolveNewFiles(string tableOfContentsName, string directory) { FileInfo[] files = new DirectoryInfo(directory).GetFiles("*", SearchOption.AllDirectories); foreach (FileInfo file in files) { string[] pathLayers = Regex.Split(file.FullName.Substring(directory.Length), "(?:(bundles)|(chunks)|(ebx)|(res)|(chunkMeta)|(dbx))\\\\").Select(substring => substring.Trim('\\').Replace('\\', '/')).Where(_ => !String.IsNullOrEmpty(_)).ToArray(); BundleList bundleList = myTableOfContents.Payload.BundleCollections.SingleOrDefault(_ => _.Name == pathLayers[0]); if (bundleList != null) { SuperBundle correspondingBundle = null; // no indirection if (pathLayers.Length == 2) { correspondingBundle = bundleList.Bundles.SingleOrDefault(bundle => ((byte[])bundle.Properties["id"].Value).SequenceEqual(Helpers.StringToByteArray(pathLayers[1]))); } // indirection else { IEnumerable <SuperBundle> superBundles = bundleList.Bundles .Where(bundle => (string)bundle.Properties["id"].Value == pathLayers[1].Replace("_Dq_", ":")); if (superBundles != null) { BundleList indirectBundleList = superBundles.SelectMany(bundle => bundle.Indirection.BundleCollections .Where(list => list.Name == pathLayers[2])) .SingleOrDefault(); if (indirectBundleList != null) { correspondingBundle = indirectBundleList.Bundles .SingleOrDefault(bundle => bundle.Properties.ContainsKey("name") ? (string)bundle.Properties["name"].Value == pathLayers[3] : ((byte[])bundle.Properties["id"].Value).SequenceEqual(Helpers.StringToByteArray(pathLayers[3]))); } } } if (correspondingBundle != null) { correspondingBundle.Changed = file.FullName; } } } }