MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / with_tmp_xdg

Function with_tmp_xdg

crates/openshell-cli/src/main.rs:3202–3217  ·  view source on GitHub ↗
(tmp: &std::path::Path, f: F)

Source from the content-addressed store, hash-verified

3200 /// then restore the original value.
3201 #[allow(unsafe_code)]
3202 fn with_tmp_xdg<F: FnOnce()>(tmp: &std::path::Path, f: F) {
3203 let _guard = XDG_LOCK
3204 .lock()
3205 .unwrap_or_else(std::sync::PoisonError::into_inner);
3206 let orig = std::env::var("XDG_CONFIG_HOME").ok();
3207 unsafe {
3208 std::env::set_var("XDG_CONFIG_HOME", tmp);
3209 }
3210 f();
3211 unsafe {
3212 match orig {
3213 Some(v) => std::env::set_var("XDG_CONFIG_HOME", v),
3214 None => std::env::remove_var("XDG_CONFIG_HOME"),
3215 }
3216 }
3217 }
3218
3219 fn edge_metadata(name: &str, endpoint: &str) -> GatewayMetadata {
3220 GatewayMetadata {

Calls

no outgoing calls