Пример #1
0
        public bool Remove(PagedContainerEntry entry)
        {
            if (!entries.ContainsKey(entry.Name))
            {
                return(false);
            }

            entries.Remove(entry.Name);
            Modified = true;

            return(true);
        }
Пример #2
0
        /// <summary> Read data from pages, starting with entry.FirstPage </summary>
        internal static byte[] ReadEntryPageSequence(this Stream stm, PagedContainerHeader header, PagedContainerEntry entry)
        {
            using var stmCollector = new MemoryStream(entry.Length); // todo replace with byte[]

            var remainLength     = entry.Flags.HasFlag(EntryFlags.Compressed) ? entry.CompressedLength : entry.Length;
            var currentPageIndex = entry.FirstPage;
            var buff             = new byte[header.PageSize];

            while (currentPageIndex > 0)
            {
                stm.Position = currentPageIndex * header.PageSize;
                stm.Read(buff, 0, header.PageSize);

                var requestLength = remainLength > header.PageUserDataSize ? header.PageUserDataSize : remainLength;
                stmCollector.Write(buff, 0, requestLength);
                remainLength -= requestLength;

                currentPageIndex = BitConverter.ToInt32(buff, header.PageUserDataSize);
            }

            return(header.DataHandler.Unpack(stmCollector.ToArray()).ToArray());
        }
Пример #3
0
 public void Update(PagedContainerEntry entry, int pageFirst, int pageLast, int rawLength, int compressedLength, EntryFlags flags)
 {
     entry.Update(pageFirst, pageLast, rawLength, compressedLength, flags);
     Modified = true;
 }
Пример #4
0
 public void Add(PagedContainerEntry entry)
 {
     entries.Add(entry.Name, entry);
     Modified = true;
 }
Пример #5
0
 internal EntryReadonlyStream(PagedContainerAbstract parent, PagedContainerEntry entry)
 {
     this.parent = parent;
     this.entry  = entry;
     pages       = parent.Stream.ReadPageSequence(parent.Header, entry.FirstPage);
 }