-
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.
Contact me if something doesn't work right!
- Loading branch information
1 parent
c522391
commit c0f0e50
Showing
4 changed files
with
45 additions
and
2 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
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,5 @@ | ||
module bindbc.zstandard; | ||
|
||
public import bindbc.zstandard.dynload; | ||
public import bindbc.zstandard.zstd; | ||
public import bindbc.zstandard.config; |
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,33 @@ | ||
module test; | ||
|
||
import bindbc.zstandard; | ||
import bindbc.loader.sharedlib; | ||
|
||
import std.stdio; | ||
import std.conv : to; | ||
/* | ||
For testing dynamic linkage | ||
*/ | ||
|
||
unittest{ | ||
if(loadZstandard("G:/Developing/zstd-v1.3.7-win32/dll/libzstd.dll") == ZSTDSupport.noLibrary){ | ||
const(ErrorInfo)[] errorlist = errors; | ||
foreach(e; errorlist){ | ||
writeln(to!string(e.error)); | ||
writeln(to!string(e.message)); | ||
} | ||
|
||
} | ||
ubyte[] origFile, compOut, decompOut; | ||
|
||
File file = File("zstd.exe"); | ||
origFile.length = cast(size_t)file.size; | ||
decompOut.length = cast(size_t)file.size; | ||
compOut.length = cast(size_t)file.size; | ||
file.rawRead(origFile); | ||
size_t outputSize = ZSTD_compress(compOut.ptr, compOut.length, origFile.ptr, origFile.length, ZSTD_maxCLevel()); | ||
ZSTD_decompress(decompOut.ptr, decompOut.length, compOut.ptr, outputSize); | ||
for(int i ; i < origFile.length ; i++){ | ||
assert(decompOut[i] == origFile[i], "Error at position " ~ to!string(i)); | ||
} | ||
} |