public static List <ArchiveItem> ReadItems(Stream stream, ArchiveMetaData metadata)
        {
            if (!stream.CanRead)
            {
                throw new IOException("this stream does not support read access");
            }

            var result = new List <ArchiveItem>();

            using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
            {
                if (metadata.Raw.Version == 1)
                {
                    foreach (var file in metadata.Raw.ItemInfos)
                    {
                        // read a file data
                        stream.Position = metadata.PayloadBeginOffset + int.Parse(file.Offset);
                        var buffer = reader.ReadBytes(int.Parse(file.Length));

                        result.Add(new ArchiveItem(file.Path, buffer));
                    }
                }
                else
                {
                    throw new FormatException("format version is not supported");
                }
            }

            return(result);
        }
        public static ArchiveItem ReadItem(Stream stream, ArchiveMetaData metadata, ArchiveItemInfo itemInfo)
        {
            if (!stream.CanRead)
            {
                throw new IOException("this stream does not support read access");
            }

            using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
            {
                if (metadata.Raw.Version == 1)
                {
                    // read a file data
                    stream.Position = metadata.PayloadBeginOffset + int.Parse(itemInfo.Offset);
                    var buffer = reader.ReadBytes(int.Parse(itemInfo.Length));

                    return(new ArchiveItem(itemInfo.Path, buffer));
                }
                else
                {
                    throw new FormatException("format version is not supported");
                }
            }
        }