MCPcopy Create free account
hub / github.com/Recordscript/recordscript / patch

Function patch

libs/hbb_common/src/config.rs:397–424  ·  view source on GitHub ↗
(path: PathBuf)

Source from the content-addressed store, hash-verified

395
396#[cfg(not(any(target_os = "android", target_os = "ios")))]
397fn patch(path: PathBuf) -> PathBuf {
398 if let Some(_tmp) = path.to_str() {
399 #[cfg(windows)]
400 return _tmp
401 .replace(
402 "system32\\config\\systemprofile",
403 "ServiceProfiles\\LocalService",
404 )
405 .into();
406 #[cfg(target_os = "macos")]
407 return _tmp.replace("Application Support", "Preferences").into();
408 #[cfg(target_os = "linux")]
409 {
410 if _tmp == "/root" {
411 if let Ok(user) = crate::platform::linux::run_cmds_trim_newline("whoami") {
412 if user != "root" {
413 let cmd = format!("getent passwd '{}' | awk -F':' '{{print $6}}'", user);
414 if let Ok(output) = crate::platform::linux::run_cmds_trim_newline(&cmd) {
415 return output.into();
416 }
417 return format!("/home/{user}").into();
418 }
419 }
420 }
421 }
422 }
423 path
424}
425
426impl Config2 {
427 fn load() -> Config2 {

Callers 2

get_homeMethod · 0.85
pathMethod · 0.85

Calls 1

run_cmds_trim_newlineFunction · 0.85

Tested by

no test coverage detected