Esempio n. 1
0
    private void ExtractFiles(ZipInputStream zipStream, string?subDir, IBuilder builder)
    {
        while (zipStream.GetNextEntry() is {} entry)
        {
            Handler.CancellationToken.ThrowIfCancellationRequested();

            string?relativePath = NormalizePath(entry.Name, subDir);
            if (string.IsNullOrEmpty(relativePath))
            {
                continue;
            }

            if (entry.IsDirectory)
            {
                builder.AddDirectory(relativePath);
            }
            else if (entry.IsFile)
            {
                builder.AddFile(relativePath, zipStream.WithLength(entry.Size), GetTimestamp(entry));
            }
        }
    }