wasSharp – Diff between revs 12 and 24

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 12 Rev 24
Line 4... Line 4...
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
Line 6... Line 6...
6   6  
7 using System.Collections.Generic; 7 using System.Collections.Generic;
-   8 using System.IO;
8 using System.IO; 9 using System.IO.Compression;
9 using System.Linq; 10 using System.Linq;
-   11 using System.Text;
Line 10... Line 12...
10 using System.Text; 12 using System.Threading.Tasks;
11   13  
12 namespace wasSharp 14 namespace wasSharp
13 { 15 {
Line 35... Line 37...
35 { 37 {
36 return Path.GetInvalidFileNameChars() 38 return Path.GetInvalidFileNameChars()
37 .Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty)); 39 .Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty));
38 } 40 }
Line -... Line 41...
-   41  
-   42 public static async Task DeflateCompress(this Stream uncompressedSourceStream,
-   43 Stream compressedDestinationStream, bool leaveOpen = false)
-   44 {
-   45 using (
-   46 var compressionStream = new DeflateStream(compressedDestinationStream, CompressionMode.Compress,
-   47 leaveOpen))
-   48 {
-   49 await uncompressedSourceStream.CopyToAsync(compressionStream);
-   50 }
-   51 }
-   52  
-   53 public static async Task DeflateDecompress(this Stream compressedSourceStream,
-   54 Stream uncompressedDestinationStream, bool leaveOpen = false)
-   55 {
-   56 using (
-   57 var decompressionStream = new DeflateStream(compressedSourceStream, CompressionMode.Decompress,
-   58 leaveOpen))
-   59 {
-   60 await decompressionStream.CopyToAsync(uncompressedDestinationStream);
-   61 }
-   62 }
-   63  
-   64 public static async Task GZipCompress(this Stream uncompressedSourceStream, Stream compressedDestinationStream,
-   65 bool leaveOpen = false)
-   66 {
-   67 using (
-   68 var compressionStream = new GZipStream(compressedDestinationStream, CompressionMode.Compress, leaveOpen)
-   69 )
-   70 {
-   71 await uncompressedSourceStream.CopyToAsync(compressionStream);
-   72 }
-   73 }
-   74  
-   75 public static async Task GZipDecompress(this Stream compressedSourceStream, Stream uncompressedDestinationStream,
-   76 bool leaveOpen = false)
-   77 {
-   78 using (
-   79 var decompressionStream = new GZipStream(compressedSourceStream, CompressionMode.Decompress, leaveOpen))
-   80 {
-   81 await decompressionStream.CopyToAsync(uncompressedDestinationStream);
-   82 }
-   83 }
-   84  
-   85 public static string MimeType(string fileName, char extensionSeparator = '.')
-   86 {
-   87 switch (fileName.Split('.').Last().ToUpperInvariant())
-   88 {
-   89 case "AVI":
-   90 return "video/x-msvideo";
-   91 case "CSS":
-   92 return "text/css";
-   93 case "DOC":
-   94 return "application/msword";
-   95 case "GIF":
-   96 return "image/gif";
-   97 case "HTM":
-   98 case "HTML":
-   99 return "text/html";
-   100 case "JPG":
-   101 case "JPEG":
-   102 return "image/jpeg";
-   103 case "JS":
-   104 return "application/x-javascript";
-   105 case "MP3":
-   106 return "audio/mpeg";
-   107 case "PNG":
-   108 return "image/png";
-   109 case "PDF":
-   110 return "application/pdf";
-   111 case "PPT":
-   112 return "application/vnd.ms-powerpoint";
-   113 case "ZIP":
-   114 return "application/zip";
-   115 case "TXT":
-   116 return "text/plain";
-   117 case "XML":
-   118 return "text/xml";
-   119 case "SQLITE":
-   120 return "application/x-sqlite3";
-   121 default:
-   122 return "application/octet-stream";
-   123 }
-   124 }
39   125  
40 /////////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////////
41 // Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 // 127 // Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
42 /////////////////////////////////////////////////////////////////////////// 128 ///////////////////////////////////////////////////////////////////////////
43 /// <summary> 129 /// <summary>