Skip to main content

validate_local_path_for_create

Function validate_local_path_for_create 

Source
pub fn validate_local_path_for_create(path: &str) -> Result<PathBuf, McpError>
Expand description

Validate a LocalFile path for the create-if-missing code path.

Looser than validate_local_path in one respect only: the target file itself need not exist yet. Everything else โ€” absolute path, parent must exist, no .. components after canonicalization โ€” is enforced identically. Delegates to validate_local_path when the file is already present so the two paths produce the same canonical output.

ยงErrors

  • Returns ErrorCode::InvalidArgument if path is relative, has no parent directory, has no file-name component, or if the canonicalized parent contains .. components.
  • Returns ErrorCode::FileNotFound if the parent directory does not exist (canonicalization fails).
  • Delegates to validate_local_path when the file already exists, producing the same errors as that function.