We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aaefb1d commit 0215608Copy full SHA for 0215608
src/bindings/system/fs.rs
@@ -1,5 +1,6 @@
1
use rlua::prelude::*;
2
use std::sync::Arc;
3
+use std::env;
4
use std::fs;
5
use serde_json;
6
use rlua_serde;
@@ -63,6 +64,10 @@ pub fn init(lua: &Lua) -> ::Result<()> {
63
64
Ok(lua.create_string(&String::from_utf8_lossy(&data[..]).to_owned().to_string())?)
65
})?)?;
66
67
+ module.set("chdir", lua.create_function(|_, path: String| {
68
+ env::set_current_dir(path).map_err(LuaError::external)
69
+ })?)?;
70
+
71
module.set("exists", lua.create_function( |_, path: String| {
72
Ok(::std::path::Path::new(&path).exists())
73
0 commit comments