mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Split directory creation into another branch
This commit is contained in:
parent
578de55d98
commit
30ceab70a2
1 changed files with 0 additions and 13 deletions
|
|
@ -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),
|
||||
|
|
@ -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") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue