Exemple #1
0
        public async Task Accept(INodeVisitor visitor)
        {
            // Extract the file to a temporary file, and then parse that.
            using (var tempFile = new TempFile())
            {
                // Extract to the temporary file
                using (var tempStream = tempFile.OpenWrite())
                    using (var stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
                        using (var gzipFile = new GZipStream(stream, CompressionMode.Decompress, false))
                        {
                            await gzipFile.CopyToAsync(tempStream);
                        }

                // Process the extracted file
                await visitor.Visit(new FileNode(tempFile.File));
            }
        }
Exemple #2
0
        public async Task Accept(INodeVisitor visitor)
        {
            using (var zipSource = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
                using (var zipFile = new ZipArchive(zipSource, ZipArchiveMode.Read, true))
                {
                    foreach (var entry in zipFile.Entries)
                    {
                        using (var entryStream = entry.Open())
                            using (var tempFile = new TempFile())
                            {
                                using (var tempStream = tempFile.OpenWrite())
                                {
                                    await entryStream.CopyToAsync(tempStream, visitor.Context.CancellationToken);
                                }

                                await visitor.Visit(new FileNode(tempFile.File));
                            }
                    }
                }
        }