Exemple #1
0
            Dictionary <string, PackageEntry> ParseIndex(Dictionary <uint, PackageEntry> entries, HashSet <string> allPossibleFilenames)
            {
                var classicIndex = new Dictionary <string, PackageEntry>();
                var crcIndex     = new Dictionary <string, PackageEntry>();

                // Try and find a local mix database
                var dbNameClassic = PackageEntry.HashFilename("local mix database.dat", PackageHashType.Classic);
                var dbNameCRC     = PackageEntry.HashFilename("local mix database.dat", PackageHashType.CRC32);

                foreach (var kv in entries)
                {
                    if (kv.Key == dbNameClassic || kv.Key == dbNameCRC)
                    {
                        using (var content = GetContent(kv.Value))
                        {
                            var db = new XccLocalDatabase(content);
                            foreach (var e in db.Entries)
                            {
                                allPossibleFilenames.Add(e);
                            }
                        }

                        break;
                    }
                }

                foreach (var filename in allPossibleFilenames)
                {
                    var          classicHash = PackageEntry.HashFilename(filename, PackageHashType.Classic);
                    var          crcHash     = PackageEntry.HashFilename(filename, PackageHashType.CRC32);
                    PackageEntry e;

                    if (entries.TryGetValue(classicHash, out e))
                    {
                        classicIndex.Add(filename, e);
                    }

                    if (entries.TryGetValue(crcHash, out e))
                    {
                        crcIndex.Add(filename, e);
                    }
                }

                var bestIndex = crcIndex.Count > classicIndex.Count ? crcIndex : classicIndex;

                var unknown = entries.Count - bestIndex.Count;

                if (unknown > 0)
                {
                    Android.Util.Log.Debug("debug", "{0}: failed to resolve filenames for {1} unknown hashes".F(Name, unknown));
                }

                return(bestIndex);
            }
Exemple #2
0
 public Stream GetContent(PackageEntry entry)
 {
     return(SegmentStream.CreateWithoutOwningStream(s, dataStart + entry.Offset, (int)entry.Length));
 }