mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 12:44:16 +01:00
Cleanup util
This commit is contained in:
parent
321f39dc55
commit
6d9f7584d6
1 changed files with 14 additions and 23 deletions
|
|
@ -216,7 +216,7 @@ namespace Dalamud.Utility
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compress a string using GZip.
|
/// Compress a string using GZip.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">The input string.</param>
|
/// <param name="str">The input string.</param>
|
||||||
/// <returns>The compressed output bytes.</returns>
|
/// <returns>The compressed output bytes.</returns>
|
||||||
|
|
@ -224,35 +224,29 @@ namespace Dalamud.Utility
|
||||||
{
|
{
|
||||||
var bytes = Encoding.UTF8.GetBytes(str);
|
var bytes = Encoding.UTF8.GetBytes(str);
|
||||||
|
|
||||||
using (var msi = new MemoryStream(bytes))
|
using var msi = new MemoryStream(bytes);
|
||||||
using (var mso = new MemoryStream())
|
using var mso = new MemoryStream();
|
||||||
{
|
using var gs = new GZipStream(mso, CompressionMode.Compress);
|
||||||
using (var gs = new GZipStream(mso, CompressionMode.Compress))
|
|
||||||
{
|
|
||||||
CopyTo(msi, gs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mso.ToArray();
|
CopyTo(msi, gs);
|
||||||
}
|
|
||||||
|
return mso.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decompress a string using GZip.
|
/// Decompress a string using GZip.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bytes">The input bytes.</param>
|
/// <param name="bytes">The input bytes.</param>
|
||||||
/// <returns>The compressed output string.</returns>
|
/// <returns>The compressed output string.</returns>
|
||||||
public static string DecompressString(byte[] bytes)
|
public static string DecompressString(byte[] bytes)
|
||||||
{
|
{
|
||||||
using (var msi = new MemoryStream(bytes))
|
using var msi = new MemoryStream(bytes);
|
||||||
using (var mso = new MemoryStream())
|
using var mso = new MemoryStream();
|
||||||
{
|
using var gs = new GZipStream(msi, CompressionMode.Decompress);
|
||||||
using (var gs = new GZipStream(msi, CompressionMode.Decompress))
|
|
||||||
{
|
|
||||||
CopyTo(gs, mso);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Encoding.UTF8.GetString(mso.ToArray());
|
CopyTo(gs, mso);
|
||||||
}
|
|
||||||
|
return Encoding.UTF8.GetString(mso.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -269,9 +263,6 @@ namespace Dalamud.Utility
|
||||||
while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0) dest.Write(bytes, 0, cnt);
|
while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0) dest.Write(bytes, 0, cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Someone implement GetUTF8String with some IntPtr overloads.
|
|
||||||
// while(Marshal.ReadByte(0, sz) != 0) { sz++; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Heuristically determine if Dalamud is running on Linux/WINE.
|
/// Heuristically determine if Dalamud is running on Linux/WINE.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue