Skip to content

Commit

Permalink
get rid of another null!
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Hathcock committed Apr 23, 2024
1 parent 9622853 commit 095b5f7
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal override Stream GetCompressedStream()
{
if (!Header.HasStream)
{
return null!;
throw new InvalidOperationException("File does not have a stream.");
}
var folderStream = _database.GetFolderStream(_stream, Folder!, _database.PasswordProvider);

Expand Down Expand Up @@ -73,32 +73,21 @@ public CompressionType CompressionType
private const uint K_PPMD = 0x030401;
private const uint K_B_ZIP2 = 0x040202;

internal CompressionType GetCompression()
private CompressionType GetCompression()
{
if (Header.IsDir)
{
return CompressionType.None;
}

var coder = Folder.NotNull()._coders.First();
switch (coder._methodId._id)
return coder._methodId._id switch
{
case K_LZMA:
case K_LZMA2:
{
return CompressionType.LZMA;
}
case K_PPMD:
{
return CompressionType.PPMd;
}
case K_B_ZIP2:
{
return CompressionType.BZip2;
}
default:
throw new NotImplementedException();
}
K_LZMA or K_LZMA2 => CompressionType.LZMA,
K_PPMD => CompressionType.PPMd,
K_B_ZIP2 => CompressionType.BZip2,
_ => throw new NotImplementedException()
};
}

internal bool IsEncrypted =>
Expand Down

0 comments on commit 095b5f7

Please sign in to comment.