Created
May 27, 2020 20:39
-
-
Save EnzoAlbornoz/87ef519ee72300943cba2b2c56f82fc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn op_mkdir( | |
state: &State, | |
args: Value, | |
_zero_copy: Option<ZeroCopyBuf>, | |
) -> Result<JsonOp, OpError> { | |
let args: MkdirArgs = serde_json::from_value(args)?; | |
let path = resolve_from_cwd(Path::new(&args.path))?; | |
let mode = args.mode.unwrap_or(0o777) & 0o777; | |
state.check_write(&path)?; | |
let is_sync = args.promise_id.is_none(); | |
blocking_json(is_sync, move || { | |
debug!("op_mkdir {} {:o} {}", path.display(), mode, args.recursive); | |
let mut builder = std::fs::DirBuilder::new(); | |
builder.recursive(args.recursive); | |
#[cfg(unix)] | |
{ | |
use std::os::unix::fs::DirBuilderExt; | |
builder.mode(mode); | |
} | |
builder.create(path)?; | |
Ok(json!({})) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment