natiny.resource.save
Lua
natiny.resource.save(resource, path) -> ok
Writes a resource's bytes to a file, replacing an existing file at that path.
Parameters
| Name |
Type |
Description |
resource |
number |
Resource handle |
path |
string |
Where to write it; an existing file is overwritten |
Returns
| Type |
Description |
boolean |
true when every byte was written |
Example
Lua
local ok = natiny.resource.save(resource, "data/copy.bin")
Notes
- The directory must already exist - this does not create one.
- The bytes go out exactly as they are: nothing is packed, framed or compressed on the way.
- A failure is reported and returns
false; the file may be left partly written.
- On web, the path is in Emscripten's virtual filesystem and normally persists
only for the current page session.