natiny.resource.pack
Lua
natiny.resource.pack(input, output [, part_size [, key]]) -> ok
Writes a folder as index.pack plus numbered pack files while
preserving resource names relative to the input folder.
Parameters
| Name |
Type |
Default |
Description |
input |
string |
|
Non-empty folder path to read recursively |
output |
string |
|
Non-empty folder path to create and write; may be the same folder as input |
part_size |
number |
0 |
Maximum uncompressed bytes per numbered pack; 0 selects 1 MiB and values from 1 to 4095 are raised to 4096 |
key |
string |
"" |
Passphrase used to encrypt the packs; an empty string writes them unencrypted |
Returns
| Type |
Description |
boolean |
true when the index and every numbered pack were written; false on failure or on an unsupported platform |
Example
Lua
local natiny = require("natiny")
if not natiny.resource.pack("data", "build/data", 0, "my secret") then
error("packing failed")
end
Notes
- Packing is supported on desktop platforms. It reports an error and returns
false on Android, iOS and the web.
- Empty files are skipped, and the complete input folder is held in memory
during packing.