Ejemplo n.º 1
0
        public void Unarchive()
        {
            using (var inputStream = new FileStream(SourcePath, FileMode.Open, FileAccess.Read))
            {
                using (var tempStream = new FileStream(SourcePath + ".tmp", FileMode.Create, FileAccess.ReadWrite))
                {
                    Compressor.GzipDecompress(inputStream, tempStream);

                    tempStream.Seek(0, SeekOrigin.Begin);

                    var header = new ArchiveEntityHeader();
                    header.ReadStream(tempStream);

                    for (int i = 0; i < header.Length; i++)
                    {
                        var archiveFile = new ArchiveFile();
                        archiveFile.ReadHeader(tempStream);
                        archiveFile.AbsolutePath = Path.Combine(TargetPath, archiveFile.RelativePath);

                        ArchiveItems.Add(archiveFile);
                    }

                    ArchiveItems.ForEach(x => x.ReadContent(tempStream));
                }

                File.Delete(SourcePath + ".tmp");
            }
        }
Ejemplo n.º 2
0
        public override void ReadHeader(Stream inputStream)
        {
            var header = new ArchiveEntityHeader();

            header.ReadStream(inputStream);

            RelativePath = header.RelativePath;
            Length       = header.Length;
            HashValue    = header.HashValue;
        }