diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2021-11-20 21:31:30 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2021-11-20 21:31:30 +0100 |
| commit | 7ff7f3902e5bdcc33bfc07fa6ad71a5798d7f8d6 (patch) | |
| tree | 6e7eaaed636558c4feb88f2bb18bbb7d4c0c87be /src/IOL.Helpers/InMemoryZipArchive.cs | |
| parent | 4e41b1f31a7309b299398fd9dd53d499204fa6cf (diff) | |
| download | dotnet-helpers-7ff7f3902e5bdcc33bfc07fa6ad71a5798d7f8d6.tar.xz dotnet-helpers-7ff7f3902e5bdcc33bfc07fa6ad71a5798d7f8d6.zip | |
Change to file-scoped namespaces.
Add ConditionalWhere to QueryableHelpers.cs
Diffstat (limited to 'src/IOL.Helpers/InMemoryZipArchive.cs')
| -rw-r--r-- | src/IOL.Helpers/InMemoryZipArchive.cs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/IOL.Helpers/InMemoryZipArchive.cs b/src/IOL.Helpers/InMemoryZipArchive.cs index 8d3fc94..efb4f79 100644 --- a/src/IOL.Helpers/InMemoryZipArchive.cs +++ b/src/IOL.Helpers/InMemoryZipArchive.cs @@ -3,28 +3,27 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; -namespace IOL.Helpers +namespace IOL.Helpers; + +public static class InMemoryZipArchive { - public static class InMemoryZipArchive - { - public static byte[] Create(IEnumerable<InMemoryFile> files, string unixPermissionString = "664") { - using var archiveStream = new MemoryStream(); - using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create, true)) { - foreach (var file in files) { - var zipArchiveEntry = archive.CreateEntry(file.FileName, CompressionLevel.Fastest); - zipArchiveEntry.ExternalAttributes |= Convert.ToInt32(unixPermissionString, 8) << 16; - using var zipStream = zipArchiveEntry.Open(); - zipStream.Write(file.Content, 0, file.Content.Length); - } + public static byte[] Create(IEnumerable<InMemoryFile> files, string unixPermissionString = "664") { + using var archiveStream = new MemoryStream(); + using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create, true)) { + foreach (var file in files) { + var zipArchiveEntry = archive.CreateEntry(file.FileName, CompressionLevel.Fastest); + zipArchiveEntry.ExternalAttributes |= Convert.ToInt32(unixPermissionString, 8) << 16; + using var zipStream = zipArchiveEntry.Open(); + zipStream.Write(file.Content, 0, file.Content.Length); } - - return archiveStream.ToArray(); } - public class InMemoryFile - { - public string FileName { get; set; } - public byte[] Content { get; set; } - } + return archiveStream.ToArray(); + } + + public class InMemoryFile + { + public string FileName { get; set; } + public byte[] Content { get; set; } } } |
