-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XABT] Use ZipArchive to build APKs.
- Loading branch information
Showing
5 changed files
with
410 additions
and
109 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
46 changes: 46 additions & 0 deletions
46
src/Xamarin.Android.Build.Tasks/Utilities/UtilityExtensions.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,46 @@ | ||
using System; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using Xamarin.Tools.Zip; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
static class UtilityExtensions | ||
{ | ||
public static System.IO.Compression.CompressionLevel ToCompressionLevel (this CompressionMethod method) | ||
{ | ||
switch (method) { | ||
case CompressionMethod.Store: | ||
return System.IO.Compression.CompressionLevel.NoCompression; | ||
case CompressionMethod.Default: | ||
case CompressionMethod.Deflate: | ||
return System.IO.Compression.CompressionLevel.Optimal; | ||
default: | ||
throw new ArgumentOutOfRangeException (nameof (method), method, null); | ||
} | ||
} | ||
|
||
public static CompressionMethod ToCompressionMethod (this System.IO.Compression.CompressionLevel level) | ||
{ | ||
switch (level) { | ||
case System.IO.Compression.CompressionLevel.NoCompression: | ||
return CompressionMethod.Store; | ||
case System.IO.Compression.CompressionLevel.Optimal: | ||
return CompressionMethod.Deflate; | ||
default: | ||
throw new ArgumentOutOfRangeException (nameof (level), level, null); | ||
} | ||
} | ||
|
||
public static FileMode ToFileMode (this ZipArchiveMode mode) | ||
{ | ||
switch (mode) { | ||
case ZipArchiveMode.Create: | ||
return FileMode.Create; | ||
case ZipArchiveMode.Update: | ||
return FileMode.Open; | ||
default: | ||
throw new ArgumentOutOfRangeException (nameof (mode), mode, null); | ||
} | ||
} | ||
} |
Oops, something went wrong.