Skip to content

Commit

Permalink
Add pluto_give_file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Mar 9, 2024
1 parent 2e81c9c commit f0682f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Barring the script tags needed for PlutoScript's usage, this is the entire sourc
- `pluto_require(src)`
- `pluto_load(code)`
- `pluto_invoke(name, ...args)` can be used to invoke a global Pluto function
- `pluto_give_file(name, data)` writes a Uint8Array for Pluto code to read from the file with the given name
## Pluto API
Expand Down
7 changes: 7 additions & 0 deletions plutoscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ function pluto_invoke(name, ...args)
return pluto_invoke_impl(...args);
}

function pluto_give_file(name, data/*: Uint8Array */)
{
let stream = lib.mod.FS.open(name, "w+");
lib.mod.FS.write(stream, data, 0, data.length, 0);
lib.mod.FS.close(stream);
}

// Commands for Pluto Runtime

function pluto_cmd_fetch(src)
Expand Down

0 comments on commit f0682f0

Please sign in to comment.