Add file write operations

This commit is contained in:
lumi 2025-06-25 22:26:43 +10:00
parent 85a0110e1a
commit 014687068f
Signed by: luaneko
GPG Key ID: 406809B8763FF07A

View File

@ -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)
}
}