Skip to main content

resolve_file_path

Function resolve_file_path 

Source
pub fn resolve_file_path(user_path: &str, working_dir: &Path) -> PathBuf
Expand description

Resolve a user-provided file path against the working directory.

Handles common LLM mistakes:

  • ./src/main.rs -> strips ./ prefix
  • ~/file.rs / $HOME/file.rs -> expands home directory
  • myproject/main.rs when cwd is /home/user/myproject -> /home/user/myproject/main.rs (detects and strips redundant basename prefix)
  • Absolute paths with doubled project name
  • /workspace/foo or /testbed/foo -> {working_dir}/foo (LLM hallucination from Docker)