Add file write operations
This commit is contained in:
parent
85a0110e1a
commit
014687068f
@ -1,4 +1,5 @@
|
||||
//! The `lb:fs` library provides utilities for interacting with the file system asynchronously.
|
||||
//! The `lb:fs` library provides synchronous and asynchronous utilities for interacting with the
|
||||
//! file system.
|
||||
//!
|
||||
//! # Exports
|
||||
//!
|
||||
@ -31,4 +32,12 @@ impl lb_libfs {
|
||||
pub extern "Lua-C" fn read_sync(&self, path: &str) -> io::Result<Vec<u8>> {
|
||||
std::fs::read(path)
|
||||
}
|
||||
|
||||
pub async extern "Lua-C" fn write(&self, path: &str, contents: &[u8]) -> io::Result<()> {
|
||||
fs::write(path, contents).await
|
||||
}
|
||||
|
||||
pub extern "Lua-C" fn write_sync(&self, path: &str, contents: &[u8]) -> io::Result<()> {
|
||||
std::fs::write(path, contents)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user