diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc36a1f --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# luau-unzip + +Discord +Pesde +Lune + +A Luau library to unzip and extract files from ZIP archives. + +## Features +- Extract files from ZIP archives. +- Supports `INFLATE` and `STORE` decompression methods. +- Traverse and list archive contents. +- Retrieve archive statistics (file count, directory count, total size) and metadata. + +## Usage + +```luau +local fs = require("@lune/fs") +local zip = require("luau-unzip") + +-- Read the ZIP file +local file = fs.readFile("test.zip") + +-- Load the ZIP archive +local reader = zip.load(buffer.fromstring(file)) + +-- Print directory structure +print("Directory structure:") +reader:walk(function(entry, depth) + local prefix = string.rep(" ", depth) + local suffix = if not entry.isDirectory + then string.format(" (%d bytes), content: %s", entry.size, reader:extract(entry, { isString = true }) :: string) + else "" + print(prefix .. entry.name .. suffix) +end) + +-- List children of root directory +print("\nChildren of `/`:") +local assets = reader:listDirectory("/") +for _, entry in assets do + print(string.format(" %s - %s (%s)", entry.name, if entry.isDirectory then "DIR" else "FILE", entry.method)) +end + +-- Get archive statistics +local stats = reader:getStats() +print("\nArchive stats:") +print("Files:", stats.fileCount) +print("Directories:", stats.dirCount) +print("Total size:", stats.totalSize, "bytes") +``` + +## MSLV (Minimum Supported Luau Version) +This library requires at least Luau [0.629](https://github.com/luau-lang/luau/releases/tag/0.629). + +## License +This project is licensed under the [MIT] license. + +[MIT]: https://compeydev.mit-license.org