Exemple #1
0
        public IList <PartItem> Read()
        {
            _stream.Seek(ToStartPosition, SeekOrigin.Begin);
            var tocStartPosition = BitConverter.ToInt64(ReadValue(LargeBufferSize), 0);

            _stream.Seek(TocEndPosition, SeekOrigin.Begin);
            var tocEndPosition = BitConverter.ToInt64(ReadValue(LargeBufferSize), 0);

            _method = (CompressionMethod)BitConverter.ToInt32(ReadValue(SmallBufferSize), 0);

            var itemCount = BitConverter.ToInt32(ReadValue(SmallBufferSize), 0);

            _stream.Seek(tocStartPosition, SeekOrigin.Begin);
            var items = new List <PartItem>();

            for (var i = 0; i < itemCount; i++)
            {
                var nameSize = BitConverter.ToInt32(ReadValue(SmallBufferSize), 0);
                var item     = new PartItem
                {
                    Name           = Encoding.UTF8.GetString(ReadValue(nameSize)),
                    Size           = ReadLong(),
                    CompressedSize = ReadLong(),
                    StartPosition  = ReadLong(),
                    EndPosition    = ReadLong(),
                    CreatedDate    = DateTime.Parse(Encoding.ASCII.GetString(ReadValue(DateFormat.Length)))
                };

                items.Add(item);
            }

            return(items);
        }
Exemple #2
0
        public IList <PartItem> Read()
        {
            _stream.Seek(ToStartPosition, SeekOrigin.Begin);
            var buffer = new byte[LargeBufferSize];

            _stream.Read(buffer, 0, buffer.Length);
            var tocStartPosition = BitConverter.ToInt64(buffer, 0);

            _stream.Seek(TocEndPosition, SeekOrigin.Begin);
            buffer = new byte[LargeBufferSize];
            _stream.Read(buffer, 0, buffer.Length);
            var tocEndPosition = BitConverter.ToInt64(buffer, 0);

            buffer = new byte[SmallBufferSize];
            _stream.Read(buffer, 0, buffer.Length);
            _method = (CompressionMethod)BitConverter.ToInt32(buffer, 0);

            buffer = new byte[SmallBufferSize];
            _stream.Read(buffer, 0, buffer.Length);
            var itemCount = BitConverter.ToInt32(buffer, 0);

            _stream.Seek(tocStartPosition, SeekOrigin.Begin);
            var items = new List <PartItem>();

            for (int i = 0; i < itemCount; i++)
            {
                var item = new PartItem();

                buffer = new byte[SmallBufferSize];
                _stream.Read(buffer, 0, buffer.Length);
                var nameSize = BitConverter.ToInt32(buffer, 0);

                buffer = new byte[nameSize];
                _stream.Read(buffer, 0, buffer.Length);
                item.Name = Encoding.UTF8.GetString(buffer);

                buffer = new byte[LargeBufferSize];
                _stream.Read(buffer, 0, buffer.Length);
                item.Size = BitConverter.ToInt64(buffer, 0);

                buffer = new byte[LargeBufferSize];
                _stream.Read(buffer, 0, buffer.Length);
                item.CompressedSize = BitConverter.ToInt64(buffer, 0);

                buffer = new byte[LargeBufferSize];
                _stream.Read(buffer, 0, buffer.Length);
                item.StartPosition = BitConverter.ToInt64(buffer, 0);

                buffer = new byte[LargeBufferSize];
                _stream.Read(buffer, 0, buffer.Length);
                item.EndPosition = BitConverter.ToInt64(buffer, 0);

                buffer = new byte[DateFormat.Length];
                _stream.Read(buffer, 0, buffer.Length);
                item.CreatedDate = DateTime.Parse(Encoding.ASCII.GetString(buffer));

                items.Add(item);
            }

            return(items);
        }