Skip to content

Commit 4506a35

Browse files
authored
Merge pull request #183 from evo-lua/miniz-mem-reader
Add a reference for miniz.new_reader_memory
2 parents d79b7d2 + 47d4eff commit 4506a35

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

docs/references/api/bindings/miniz.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Applies [INFLATE](https://en.wikipedia.org/wiki/Deflate#Decoder/decompressor) to
8585

8686
## ZipFileReader
8787

88-
Created by [new_reader](#new_reader). You can use this to get information about the files within a ZIP archive or to extract them (in-memory).
88+
Created by [new_reader](#new_reader) or [new_reader_memory](#new_reader_memory). You can use this to get information about the files within a ZIP archive or to extract them (in-memory).
8989

9090
### extract
9191

@@ -377,15 +377,43 @@ Creates a new [Inflator](#inflator) object and returns a `userdata` reference to
377377

378378
### new_reader
379379

380-
Creates a new ZIP file reader for the given `fileSystemPath`. The `flags` passed to `miniz` can control the way that the archive is read.
380+
Creates a new ZIP file reader for the given `fileSystemPath`. The `flags` passed to `miniz` can control the way that the archive is read. This method will automatically load the ZIP file from disk and attempt to decode it.
381+
382+
:::info
383+
This function is suitable if loading the entire file into memory is acceptable. Use a [deflator](#deflator) for streaming.
384+
:::
385+
386+
Returns `nil` and an error message in case of failure. Otherwise the ZIP [reader](#ZipFileReader) should be ready to use.
381387

382388
<Function>
383389
<Parameters>
384390
<Parameter name="fileSystemPath" type="string"/>
385391
<Parameter name="flags" type="number" optional/>
386392
</Parameters>
387393
<Returns>
388-
<Return name="reader" type="ZipFileReader"/>
394+
<Return name="reader" type="ZipFileReader" optional/>
395+
<Return name="errorMessage" type="string" optional/>
396+
</Returns>
397+
</Function>
398+
399+
### new_reader_memory
400+
401+
Creates a new ZIP file reader for the given `fileContents`. The `flags` passed to `miniz` can control the way that the archive is read. You must handle reading the file from disk yourself, however you see fit.
402+
403+
:::info
404+
This function is suitable if loading the entire file into memory is acceptable. Use a [deflator](#deflator) for streaming.
405+
:::
406+
407+
Returns `nil` and an error message in case of failure. Otherwise the ZIP [reader](#ZipFileReader) should be ready to use.
408+
409+
<Function>
410+
<Parameters>
411+
<Parameter name="fileContents" type="string"/>
412+
<Parameter name="flags" type="number" optional/>
413+
</Parameters>
414+
<Returns>
415+
<Return name="reader" type="ZipFileReader" optional/>
416+
<Return name="errorMessage" type="string" optional/>
389417
</Returns>
390418
</Function>
391419

@@ -443,6 +471,7 @@ Returns the version number of the embedded `miniz` library as a Lua string.
443471

444472
## Changelog
445473

446-
| Version | What happened? |
447-
| :-----: | :-------------: |
448-
| v0.0.5 | Initial release |
474+
| Version | What happened? |
475+
| :-----: | :-----------------------: |
476+
| v0.0.20 | Added `new_reader_memory` |
477+
| v0.0.5 | Initial release |

0 commit comments

Comments
 (0)