Skip to main content

resolve_export_path

Function resolve_export_path 

Source
pub fn resolve_export_path(
    vault_root: &Path,
    requested: &Path,
) -> Result<PathBuf>
Expand description

Resolve a requested export path against the vault root, enforcing the vault sandbox and auto-suffixing on filename collision.

Rules:

  • Path must be vault-relative (not absolute).
  • No .. components.
  • Cannot have a .md extension (vault’s own format).
  • After joining + canonicalizing the parent, the path must stay under the canonical vault root (catches symlink escapes).
  • If a file at the target path already exists, the returned path is <stem> (1).<ext>, then <stem> (2).<ext>, etc. (macOS-style).

Returns the resolved absolute path where the export should be written. The parent directory is created as a side effect.