fix removing build directory

This commit is contained in:
AiSatan authored and meehl committed 2026-03-11 16:48:11 +01:00
1 parent 3b0d5295d3
commit 8034eef8c7
2 files changed
+15 -1

No files matched your search

+12
View File
@@ -47,3 +47,15 @@ pub fn make_dir(l: &Lua, path: String) -> LuaResult<MultiValue> {
Err(err) => Ok((Value::Nil, err.to_string()).into_lua_multi(l)?),
}
}
pub fn remove_dir(l: &Lua, (path, recursive): (String, Option<bool>)) -> LuaResult<MultiValue> {
let result = if recursive.unwrap_or(false) {
fs::remove_dir_all(&path)
} else {
fs::remove_dir(&path)
};
match result {
Ok(_) => Ok(Value::Boolean(true).into_lua_multi(l)?),
Err(err) => Ok((Value::Nil, err.to_string()).into_lua_multi(l)?),
}
}