mirror of
https://github.com/SabreTools/SabreTools.Compression.git
synced 2026-02-14 21:34:30 +00:00
Port extension code for zlib constant names from UnshieldSharp
This commit is contained in:
@@ -19,5 +19,29 @@ namespace SabreTools.Compression.zlib
|
||||
public const int Z_MEM_ERROR = (-4);
|
||||
public const int Z_BUF_ERROR = (-5);
|
||||
public const int Z_VERSION_ERROR = (-6);
|
||||
|
||||
/// <summary>
|
||||
/// Get the zlib result name from an integer
|
||||
/// </summary>
|
||||
/// <param name="result">Integer to translate to the result name</param>
|
||||
/// <returns>Name of the result, the integer as a string otherwise</returns>
|
||||
public static string ToZlibConstName(this int result)
|
||||
{
|
||||
return result switch
|
||||
{
|
||||
0 => "Z_OK",
|
||||
1 => "Z_STREAM_END",
|
||||
2 => "Z_NEED_DICT",
|
||||
|
||||
-1 => "Z_ERRNO",
|
||||
-2 => "Z_STREAM_ERROR",
|
||||
-3 => "Z_DATA_ERROR",
|
||||
-4 => "Z_MEM_ERROR",
|
||||
-5 => "Z_BUF_ERROR",
|
||||
-6 => "Z_VERSION_ERROR",
|
||||
|
||||
_ => result.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user