Skip to main content

safe_component

Function safe_component 

Source
pub fn safe_component(raw: &str) -> String
Expand description

Generate a filesystem-safe single path component from an external identifier.

Rules (applied on all platforms for cross-platform determinism):

  • Replace /, \, :, <, >, ", |, ?, *, ASCII control chars, NUL with _
  • Avoid trailing space or dot
  • Avoid Windows reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9)
  • Truncate to 200 bytes