Beispiel #1
0
        public void AddEntry(CASResult blte)
        {
            if (blte == null)
            {
                return;
            }

            // create the entry
            var entry = new EncodingCEKeyPageTable()
            {
                DecompressedSize = blte.DecompressedSize,
                CKey             = blte.CEKey,
            };

            entry.EKeys.Add(blte.EKey);

            if (CEKeys.ContainsKey(blte.CEKey))             // check if it exists
            {
                var existing = CEKeys[blte.CEKey];
                if (EKeys.ContainsKey(existing.EKeys[0]))                 // remove old layout
                {
                    EKeys.Remove(existing.EKeys[0]);
                }

                existing.EKeys[0] = blte.EKey;                 // update existing entry
            }
            else
            {
                CEKeys.Add(entry.CKey, entry);                 // new entry
            }

            AddLayoutEntry(blte);
        }
Beispiel #2
0
        /// <summary>
        /// Removes a CASRecord
        /// </summary>
        /// <param name="record"></param>
        public bool Remove(CASRecord record, TACTRepo tactRepo = null)
        {
            if (record == null)
            {
                return(false);
            }

            if (_CKeyEntries.TryGetValue(record.CKey, out var entry))
            {
                _CKeyEntries.Remove(record.CKey);
                _EKeyEntries.Remove(entry.EKey);

                // propagate removal
                if (tactRepo != null)
                {
                    tactRepo.IndexContainer?.Remove(entry.EKey);
                    tactRepo.DownloadFile?.Remove(entry.EKey);
                    tactRepo.DownloadSizeFile?.Remove(entry.EKey);
                }

                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Adds a CASRecord to the EncodingFile generating all required entries. This will overwrite existing entries
        /// </summary>
        /// <param name="record"></param>
        public void AddOrUpdate(CASRecord record)
        {
            // CKeyPageTable
            if (_CKeyEntries.TryGetValue(record.CKey, out var cKeyEntry))
            {
                _EKeyEntries.Remove(cKeyEntry.EKey);
                cKeyEntry.EKey = record.EKey;
            }
            else
            {
                cKeyEntry = new EncodingContentEntry
                {
                    CKey             = record.CKey,
                    EKey             = record.EKey,
                    DecompressedSize = record.EBlock.DecompressedSize,
                };

                _CKeyEntries.Add(record.CKey, cKeyEntry);
            }

            // get or add to the ESpecStringTable
            int especIndex = ESpecStringTable.IndexOf(record.ESpec);

            if (especIndex == -1)
            {
                especIndex = ESpecStringTable.Count - 2;
                ESpecStringTable.Insert(especIndex, record.ESpec);
            }

            // EKeyPageTable
            var eKeyEntry = new EncodingEncodedEntry()
            {
                CompressedSize = record.EBlock.CompressedSize,
                EKey           = record.EKey,
                ESpecIndex     = (uint)especIndex
            };

            _EKeyEntries[record.EKey] = eKeyEntry;
        }
Beispiel #4
0
 public void Remove(EncodingEncodedEntry entry)
 {
     _EKeyEntries.Remove(entry.EKey);
 }