mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14: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>
|
||||
/// Compress a string using GZip.
|
||||
/// Compress a string using GZip.
|
||||
/// </summary>
|
||||
/// <param name="str">The input string.</param>
|
||||
/// <returns>The compressed output bytes.</returns>
|
||||
|
|
@ -224,35 +224,29 @@ namespace Dalamud.Utility
|
|||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
|
||||
using (var msi = new MemoryStream(bytes))
|
||||
using (var mso = new MemoryStream())
|
||||
{
|
||||
using (var gs = new GZipStream(mso, CompressionMode.Compress))
|
||||
{
|
||||
CopyTo(msi, gs);
|
||||
}
|
||||
using var msi = new MemoryStream(bytes);
|
||||
using var mso = new MemoryStream();
|
||||
using var gs = new GZipStream(mso, CompressionMode.Compress);
|
||||
|
||||
return mso.ToArray();
|
||||
}
|
||||
CopyTo(msi, gs);
|
||||
|
||||
return mso.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decompress a string using GZip.
|
||||
/// Decompress a string using GZip.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The input bytes.</param>
|
||||
/// <returns>The compressed output string.</returns>
|
||||
public static string DecompressString(byte[] bytes)
|
||||
{
|
||||
using (var msi = new MemoryStream(bytes))
|
||||
using (var mso = new MemoryStream())
|
||||
{
|
||||
using (var gs = new GZipStream(msi, CompressionMode.Decompress))
|
||||
{
|
||||
CopyTo(gs, mso);
|
||||
}
|
||||
using var msi = new MemoryStream(bytes);
|
||||
using var mso = new MemoryStream();
|
||||
using var gs = new GZipStream(msi, CompressionMode.Decompress);
|
||||
|
||||
return Encoding.UTF8.GetString(mso.ToArray());
|
||||
}
|
||||
CopyTo(gs, mso);
|
||||
|
||||
return Encoding.UTF8.GetString(mso.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -269,9 +263,6 @@ namespace Dalamud.Utility
|
|||
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>
|
||||
/// Heuristically determine if Dalamud is running on Linux/WINE.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue