Debian Codegraph @

src/system/file/tmpdir.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::{CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#, OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#};
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/ffi/::OsStringExtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/ffi/os_str/OsStringExt#;
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
5
6 pub(craterust-analyzer cargo sudo-rs 0.2.14 crate/) fn create_temporary_dirrust-analyzer cargo sudo-rs 0.2.14 system/file/tmpdir/create_temporary_dir().() -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> {
7 let template = c"/tmp/sudoers-XXXXXX".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CStr][ToOwned]to_owned().();
8
9 // SAFETY: mkdtemp is passed a valid null-terminated C string
10 let ptr = unsafe { libcrust-analyzer cargo libc 0.2.186 crate/::mkdtemprust-analyzer cargo libc 0.2.186 mkdtemp().(template.into_rawrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]into_raw().()) };
11
12 if ptr.is_nullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/mut_ptr/impl#[`*mut T`]is_null().() {
13 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().());
14 }
15
16 // SAFETY: ptr is the same pointer produced by into_raw() above, and it
17 // is still pointing to a zero-terminated C string
18 let path = OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::from_vecrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/ffi/os_str/impl#[OsString][OsStringExt]from_vec().(unsafe { CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::from_rawrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]from_raw().(ptr) }.into_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]into_bytes().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
19
20 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(path)
21 }