-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui: add compress and decompress for lz4 and zst, decompress for xz
- Loading branch information
mahoshojoHCG
committed
Jun 27, 2024
1 parent
59a16db
commit bfdb87b
Showing
14 changed files
with
204 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
WinPartFlash.Gui/Compression/Lz4CompressionStreamCopier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using K4os.Compression.LZ4.Streams; | ||
|
||
namespace WinPartFlash.Gui.Compression; | ||
|
||
public class Lz4CompressionStreamCopier : ICompressionStreamCopier | ||
{ | ||
public async ValueTask CopyToStreamAsync(Stream sourceStream, Stream outputStream) | ||
{ | ||
await using var compressionStream = LZ4Stream.Encode(outputStream); | ||
await sourceStream.CopyToAsync(compressionStream); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
WinPartFlash.Gui/Compression/Lz4DecompressionStreamCopier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using K4os.Compression.LZ4.Streams; | ||
|
||
namespace WinPartFlash.Gui.Compression; | ||
|
||
public class Lz4DecompressionStreamCopier : ICompressionStreamCopier | ||
{ | ||
public async ValueTask CopyToStreamAsync(Stream sourceStream, Stream outputStream) | ||
{ | ||
await using var decompressionStream = LZ4Stream.Decode(sourceStream); | ||
await decompressionStream.CopyToAsync(outputStream); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
WinPartFlash.Gui/Compression/XzDecompressionStreamCopier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using SharpCompress.Compressors.Xz; | ||
|
||
namespace WinPartFlash.Gui.Compression; | ||
|
||
public class XzDecompressionStreamCopier : ICompressionStreamCopier | ||
{ | ||
public async ValueTask CopyToStreamAsync(Stream sourceStream, Stream outputStream) | ||
{ | ||
await using var decompressionStream = new XZStream(sourceStream); | ||
await decompressionStream.CopyToAsync(outputStream); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
WinPartFlash.Gui/Compression/ZstandardCompressionStreamCopier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using ZstdSharp; | ||
|
||
namespace WinPartFlash.Gui.Compression; | ||
|
||
public class ZstandardCompressionStreamCopier : ICompressionStreamCopier | ||
{ | ||
public async ValueTask CopyToStreamAsync(Stream sourceStream, Stream outputStream) | ||
{ | ||
await using var compressionStream = new CompressionStream(outputStream); | ||
await sourceStream.CopyToAsync(compressionStream); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
WinPartFlash.Gui/Compression/ZstandardDecompressionStreamCopier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using ZstdSharp; | ||
|
||
namespace WinPartFlash.Gui.Compression; | ||
|
||
public class ZstandardDecompressionStreamCopier : ICompressionStreamCopier | ||
{ | ||
public async ValueTask CopyToStreamAsync(Stream sourceStream, Stream outputStream) | ||
{ | ||
await using var decompressionStream = new DecompressionStream(sourceStream); | ||
await decompressionStream.CopyToAsync(outputStream); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace WinPartFlash.Gui.Utils; | ||
|
||
public static class FileNameHelpers | ||
{ | ||
public const string FileExtensionGzip = ".gz"; | ||
public const string FileExtensionXz = ".xz"; | ||
public const string FileExtensionLz4 = ".lz4"; | ||
public const string FileExtensionZstandard = ".zst"; | ||
|
||
public const string FileExtensionImage = ".img"; | ||
|
||
|
||
public const string ContentTypeGzip = "application/gzip"; | ||
public const string ContentTypeGzipDeprecated = "application/x-gzip"; | ||
public const string ContentTypeXz = "application/x-xz"; | ||
public const string ContentTypeLz4 = "application/x-lz4"; | ||
public const string ContentTypeZstandard = "application/x-zstd"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.