-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eaa7451
commit 2f8d380
Showing
20 changed files
with
474 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: NuGet Push | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 8.0.x | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore ./src | ||
|
||
- name: Build | ||
run: dotnet build ./src --no-restore --configuration Release | ||
|
||
- name: Pack NuGet Package(s) | ||
run: dotnet pack ./src --no-restore --no-build --configuration Release --output ./nuget-packages | ||
|
||
- name: Upload Build Artifact(s) | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: nuget-packages | ||
path: ./nuget-packages | ||
|
||
- name: Push NuGet Package(s) | ||
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate | ||
env: | ||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
using Xunit; | ||
|
||
namespace OodleDotNet.Tests; | ||
|
||
public class Tests | ||
{ | ||
private readonly Oodle _oodle = new(Path.Combine( | ||
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), | ||
@"Libraries\oo2core_9_win64.dll")); | ||
|
||
[Fact] | ||
public void CompressAndDecompress() | ||
{ | ||
const OodleCompressor compressor = OodleCompressor.Kraken; | ||
var randomString = GetRandomString(8192); | ||
var randomStringBuffer = Encoding.ASCII.GetBytes(randomString); | ||
|
||
var compressedBufferSize = _oodle.GetCompressedBufferSizeNeeded(compressor, randomStringBuffer.Length); | ||
Assert.NotEqual(0, compressedBufferSize); | ||
|
||
var compressedBuffer = new byte[compressedBufferSize]; | ||
var compressedSize = (int)_oodle.Compress(compressor, OodleCompressionLevel.Max, randomStringBuffer, compressedBuffer); | ||
Assert.NotEqual(0, compressedSize); | ||
|
||
var decompressedBuffer = new byte[randomStringBuffer.Length]; | ||
var decompressedSize = (int)_oodle.Decompress(compressedBuffer.AsSpan(0, compressedSize), decompressedBuffer); | ||
Assert.NotEqual(0, decompressedSize); | ||
|
||
Assert.Equal(decompressedSize, randomStringBuffer.Length); | ||
Assert.True(randomStringBuffer.AsSpan().SequenceEqual(decompressedBuffer)); | ||
} | ||
|
||
private static string GetRandomString(int length) | ||
{ | ||
const string chars = "0123456789ABCDEF"; | ||
var result = new string('\0', length); | ||
var resultReadonlySpan = result.AsSpan(); | ||
var resultSpan = MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in resultReadonlySpan.GetPinnableReference()), length); | ||
|
||
for (var i = 0; i < resultSpan.Length; i++) | ||
{ | ||
resultSpan[i] = chars[Random.Shared.Next(chars.Length)]; | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
namespace OodleDotNet; | ||
|
||
public enum OodleVerbosity | ||
{ | ||
None = 0, | ||
Minimal = 1, | ||
Some = 2, | ||
Lots = 3, | ||
Force32 = 0x40000000 | ||
} | ||
|
||
public enum OodleFuzzSafe | ||
{ | ||
No = 0, | ||
Yes = 1 | ||
} | ||
|
||
public enum OodleCheckCRC | ||
{ | ||
No = 0, | ||
Yes = 1, | ||
Force32 = 0x40000000 | ||
} | ||
|
||
public enum OodleDecodeThreadPhase | ||
{ | ||
Phase1 = 1, | ||
Phase2 = 2, | ||
All = 3, | ||
Unthreaded = All | ||
} | ||
|
||
public enum OodleCompressionLevel | ||
{ | ||
/// <summary> | ||
/// don't compress, just copy raw bytes | ||
/// </summary> | ||
None=0, | ||
/// <summary> | ||
/// super fast mode, lower compression ratio | ||
/// </summary> | ||
SuperFast=1, | ||
/// <summary> | ||
/// fastest LZ mode with still decent compression ratio | ||
/// </summary> | ||
VeryFast=2, | ||
/// <summary> | ||
/// fast - good for daily use | ||
/// </summary> | ||
Fast=3, | ||
/// <summary> | ||
/// standard medium speed LZ mode | ||
/// </summary> | ||
Normal=4, | ||
|
||
/// <summary> | ||
/// optimal parse level 1 (faster optimal encoder) | ||
/// </summary> | ||
Optimal1=5, | ||
/// <summary> | ||
/// optimal parse level 2 (recommended baseline optimal encoder) | ||
/// </summary> | ||
Optimal2=6, | ||
/// <summary> | ||
/// optimal parse level 3 (slower optimal encoder) | ||
/// </summary> | ||
Optimal3=7, | ||
/// <summary> | ||
/// optimal parse level 4 (very slow optimal encoder) | ||
/// </summary> | ||
Optimal4=8, | ||
/// <summary> | ||
/// optimal parse level 5 (don't care about encode speed, maximum compression) | ||
/// </summary> | ||
Optimal5=9, | ||
|
||
/// <summary> | ||
/// faster than SuperFast, less compression | ||
/// </summary> | ||
HyperFast1=-1, | ||
/// <summary> | ||
/// faster than HyperFast1, less compression | ||
/// </summary> | ||
HyperFast2=-2, | ||
/// <summary> | ||
/// faster than HyperFast2, less compression | ||
/// </summary> | ||
HyperFast3=-3, | ||
/// <summary> | ||
/// fastest, less compression | ||
/// </summary> | ||
HyperFast4=-4, | ||
|
||
/// <summary> | ||
/// alias hyperfast base level | ||
/// </summary> | ||
HyperFast=HyperFast1, | ||
/// <summary> | ||
/// alias optimal standard level | ||
/// </summary> | ||
Optimal = Optimal2, | ||
/// <summary> | ||
/// maximum compression level | ||
/// </summary> | ||
Max = Optimal5, | ||
/// <summary> | ||
/// fastest compression level | ||
/// </summary> | ||
Min = HyperFast4, | ||
|
||
Force32 = 0x40000000, | ||
Invalid = Force32 | ||
} | ||
|
||
public enum OodleCompressor | ||
{ | ||
Invalid = -1, | ||
/// <summary> | ||
/// None = memcpy, pass through uncompressed bytes | ||
/// </summary> | ||
None = 3, | ||
|
||
/// <summary> | ||
/// Fast decompression and high compression ratios, amazing! | ||
/// </summary> | ||
Kraken = 8, | ||
/// <summary> | ||
/// Leviathan = Kraken's big brother with higher compression, slightly slower decompression. | ||
/// </summary> | ||
Leviathan = 13, | ||
/// <summary> | ||
/// Mermaid is between Kraken | ||
/// </summary>& Selkie - crazy fast, still decent compression. | ||
Mermaid = 9, | ||
/// <summary> | ||
/// Selkie is a super-fast relative of Mermaid. For maximum decode speed. | ||
/// </summary> | ||
Selkie = 11, | ||
/// <summary> | ||
/// Hydra, the many-headed beast = Leviathan, Kraken, Mermaid, or Selkie (see $OodleLZ_About_Hydra) | ||
/// </summary> | ||
Hydra = 12, | ||
|
||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
BitKnit = 10, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZB16 = 4, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZNA = 7, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZH = 0, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZHLW = 1, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZNIB = 2, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZBLW = 5, | ||
/// <summary> | ||
/// no longer supported as of Oodle 2.9.0 | ||
/// </summary> | ||
LZA = 6, | ||
|
||
Count = 14, | ||
Force32 = 0x40000000 | ||
} |
Oops, something went wrong.