This commit is contained in:
sxyazi 2024-09-14 21:08:23 +08:00
parent be3f2e6291
commit ab094c2ae8
No known key found for this signature in database

View file

@ -52,21 +52,6 @@ pub fn install(lua: &Lua) -> mlua::Result<()> {
}
})?,
),
(
"create",
lua.create_async_function(|lua, (type_, url): (mlua::String, UrlRef)| async move {
let result = match type_.to_str()? {
"file" => fs::File::create(&*url).await.map(|_| ()),
"dir" => fs::create_dir(&*url).await,
_ => Err("Creation type must be 'file', 'dir'".into_lua_err())?,
};
match result {
Ok(_) => (true, Value::Nil).into_lua_multi(lua),
Err(e) => (false, e.raw_os_error()).into_lua_multi(lua),
}
})?,
),
(
"read_dir",
lua.create_async_function(|lua, (dir, options): (UrlRef, Table)| async move {