Provide single interface for dealing with Entries that are SOLID and not. #743

Open
opened 2026-01-29 22:16:47 +00:00 by claunia · 0 comments
Owner

Originally created by @adamhathcock on GitHub (Dec 9, 2025).

Originally assigned to: @adamhathcock, @Copilot on GitHub.

Issue: https://github.com/adamhathcock/sharpcompress/issues/960#issuecomment-3616319717

Sometimes you don't know if the file is a RAR or 7Zip that may have SOLID entries. The current interface requires you to know in advance about SOLID or not.

Provide an interface that doesn't require to know in advance.

ExtractAllEntries doesn't feel right to be used alongside Entry enumeration.

This is what used to work:

      public void ExtractToDirectory( string archivePath, string extractPath )
      {
          // Lock for Extraction Progress because of Singleton
          lock( extractToDictionarySyncObject )
          {
              var options = new ExtractionOptions() {
                  ExtractFullPath = true,
                  Overwrite = true
              };

              Directory.CreateDirectory( extractPath );

              using IArchive archive = ArchiveFactory.Open( archivePath );
              double totalSize = archive.Entries.Where( e => !e.IsDirectory ).Sum( e => e.Size );
              long completed = 0;

              IReader reader = archive.ExtractAllEntries();
              while( reader.MoveToNextEntry() )
              {
                  if( !reader.Entry.IsDirectory )
                  {
                      reader.WriteEntryToDirectory( extractPath, options );

                      completed += reader.Entry.Size;
                      ExtractionProgress?.Invoke( this, new ExtractionProgressEventArgs( completed / totalSize ) );
                  }
              }
          }
      }
Originally created by @adamhathcock on GitHub (Dec 9, 2025). Originally assigned to: @adamhathcock, @Copilot on GitHub. Issue: https://github.com/adamhathcock/sharpcompress/issues/960#issuecomment-3616319717 Sometimes you don't know if the file is a RAR or 7Zip that may have SOLID entries. The current interface requires you to know in advance about SOLID or not. Provide an interface that doesn't require to know in advance. `ExtractAllEntries` doesn't feel right to be used alongside Entry enumeration. This is what used to work: ``` public void ExtractToDirectory( string archivePath, string extractPath ) { // Lock for Extraction Progress because of Singleton lock( extractToDictionarySyncObject ) { var options = new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }; Directory.CreateDirectory( extractPath ); using IArchive archive = ArchiveFactory.Open( archivePath ); double totalSize = archive.Entries.Where( e => !e.IsDirectory ).Sum( e => e.Size ); long completed = 0; IReader reader = archive.ExtractAllEntries(); while( reader.MoveToNextEntry() ) { if( !reader.Entry.IsDirectory ) { reader.WriteEntryToDirectory( extractPath, options ); completed += reader.Entry.Size; ExtractionProgress?.Invoke( this, new ExtractionProgressEventArgs( completed / totalSize ) ); } } } } ```
claunia added the enhancement label 2026-01-29 22:16:47 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#743