Skip to content

Commit

Permalink
Split directory creation into another branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hankertrix committed Dec 19, 2024
1 parent 578de55 commit 30ceab7
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions yazi-plugin/src/fs/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub fn compose(lua: &Lua) -> mlua::Result<Table> {
b"open" => open(lua)?,
b"write" => write(lua)?,
b"remove" => remove(lua)?,
b"create_dir" => create_dir(lua)?,
b"read_dir" => read_dir(lua)?,
b"unique_name" => unique_name(lua)?,
_ => return Ok(Value::Nil),
Expand Down Expand Up @@ -152,18 +151,6 @@ fn remove(lua: &Lua) -> mlua::Result<Function> {
})
}

fn create_dir(lua: &Lua) -> mlua::Result<Function> {
lua.create_async_function(|lua, (dir, recursive): (UrlRef, Option<bool>)| async move {
let is_recursive = recursive.unwrap_or(false);
let result =
if is_recursive { fs::create_dir_all(&*dir).await } else { fs::create_dir(&*dir).await };
match result {
Ok(_) => (true, Value::Nil).into_lua_multi(&lua),
Err(e) => (false, Error::Io(e)).into_lua_multi(&lua),
}
})
}

fn read_dir(lua: &Lua) -> mlua::Result<Function> {
lua.create_async_function(|lua, (dir, options): (UrlRef, Table)| async move {
let glob = if let Ok(s) = options.raw_get::<mlua::String>("glob") {
Expand Down

0 comments on commit 30ceab7

Please sign in to comment.