MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / which_tracedecay_from

Function which_tracedecay_from

src/agents/mod.rs:749–772  ·  view source on GitHub ↗
(
    current_exe: Option<&Path>,
    path_var: Option<&std::ffi::OsStr>,
    cargo_target_dir: Option<&Path>,
)

Source from the content-addressed store, hash-verified

747}
748
749fn which_tracedecay_from(
750 current_exe: Option<&Path>,
751 path_var: Option<&std::ffi::OsStr>,
752 cargo_target_dir: Option<&Path>,
753) -> Option<String> {
754 if let Some(exe) = current_exe
755 .filter(|exe| is_tracedecay_exe(exe) && !is_cargo_target_binary(exe, cargo_target_dir))
756 {
757 return Some(normalize_path_separators(&exe.to_string_lossy()));
758 }
759
760 let path_match = path_var.and_then(|path_var| {
761 std::env::split_paths(path_var).find_map(|dir| {
762 let candidate = dir.join(tracedecay_bin_name());
763 (candidate.exists() && !is_cargo_target_binary(&candidate, cargo_target_dir))
764 .then(|| normalize_path_separators(&candidate.to_string_lossy()))
765 })
766 });
767 path_match.or_else(|| {
768 current_exe
769 .filter(|exe| is_tracedecay_exe(exe))
770 .map(|exe| normalize_path_separators(&exe.to_string_lossy()))
771 })
772}
773
774fn tracedecay_bin_name() -> String {
775 format!("tracedecay{}", std::env::consts::EXE_SUFFIX)

Calls 5

is_tracedecay_exeFunction · 0.85
is_cargo_target_binaryFunction · 0.85
tracedecay_bin_nameFunction · 0.85
existsMethod · 0.80