From 014687068feb10ef65fdfabb8c915bd2566eb19d Mon Sep 17 00:00:00 2001 From: luaneko Date: Wed, 25 Jun 2025 22:26:43 +1000 Subject: [PATCH] Add file write operations --- crates/lb/src/fs.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/lb/src/fs.rs b/crates/lb/src/fs.rs index 8cffd32..a06f541 100644 --- a/crates/lb/src/fs.rs +++ b/crates/lb/src/fs.rs @@ -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> { 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) + } }