wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 24  →  ?path2? @ 25
/IO.cs
@@ -39,6 +39,16 @@
.Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty));
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Compress a stream using Deflate compression.
/// </summary>
/// <param name="uncompressedSourceStream">the stream to compress</param>
/// <param name="compressedDestinationStream">the stream to write the compressed stream to</param>
/// <param name="leaveOpen">whether to leave the compression stream open</param>
/// <returns>an awaitable Task</returns>
public static async Task DeflateCompress(this Stream uncompressedSourceStream,
Stream compressedDestinationStream, bool leaveOpen = false)
{
@@ -50,6 +60,16 @@
}
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Decompress a Deflate-compressed stream.
/// </summary>
/// <param name="compressedSourceStream">the compressed stream to decompress</param>
/// <param name="uncompressedDestinationStream">the stream to write the decompressed stream to</param>
/// <param name="leaveOpen">whether to leave the stream open after decompression</param>
/// <returns>an awaitable Task</returns>
public static async Task DeflateDecompress(this Stream compressedSourceStream,
Stream uncompressedDestinationStream, bool leaveOpen = false)
{
@@ -61,6 +81,16 @@
}
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Compress a stream using GZip compression.
/// </summary>
/// <param name="uncompressedSourceStream">the stream to compress</param>
/// <param name="compressedDestinationStream">the stream to write the compressed stream to</param>
/// <param name="leaveOpen">whether to leave the stream open after compressing</param>
/// <returns>an awaitable Task</returns>
public static async Task GZipCompress(this Stream uncompressedSourceStream, Stream compressedDestinationStream,
bool leaveOpen = false)
{
@@ -72,6 +102,16 @@
}
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Decompress a GZiped stream.
/// </summary>
/// <param name="compressedSourceStream">the stream to decompress</param>
/// <param name="uncompressedDestinationStream">the stream to write the decompressed stream to</param>
/// <param name="leaveOpen">whether the decompression stream should be left open</param>
/// <returns>an awaitable Task</returns>
public static async Task GZipDecompress(this Stream compressedSourceStream, Stream uncompressedDestinationStream,
bool leaveOpen = false)
{
@@ -82,47 +122,6 @@
}
}
 
public static string MimeType(string fileName, char extensionSeparator = '.')
{
switch (fileName.Split('.').Last().ToUpperInvariant())
{
case "AVI":
return "video/x-msvideo";
case "CSS":
return "text/css";
case "DOC":
return "application/msword";
case "GIF":
return "image/gif";
case "HTM":
case "HTML":
return "text/html";
case "JPG":
case "JPEG":
return "image/jpeg";
case "JS":
return "application/x-javascript";
case "MP3":
return "audio/mpeg";
case "PNG":
return "image/png";
case "PDF":
return "application/pdf";
case "PPT":
return "application/vnd.ms-powerpoint";
case "ZIP":
return "application/zip";
case "TXT":
return "text/plain";
case "XML":
return "text/xml";
case "SQLITE":
return "application/x-sqlite3";
default:
return "application/octet-stream";
}
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////