SE-0529: Add FilePath to the Standard Library

Hi all, I've refreshed the proposal PR with the latest round of feedback: swiftlang/swift-evolution#3292.

Brief change list:

  • Anchor.driveLetter is now Unicode.Scalar? (was Character), and both driveLetter and isVerbatimComponent are now Windows-only (#if os(Windows)). Unicode.Scalar is the narrowest candidate still expressible as and comparable against a literal (anchor.driveLetter == "C") and converts cleanly to both FilePath.CodeUnit and String. The letter is presented as written, without case normalization; an unpaired surrogate yields U+FFFD. A new Alternatives Considered subsection covers the reasoning.
  • FilePath.separator is now FilePath.CodeUnit (was Character), since it's a platform-level constant more likely to feed byte-level parsing than literal comparison.
  • The closure-based C-interop accessor is renamed withCodeUnits(_:) and now passes the code-unit count excluding the NUL terminator (thanks @glessard). nullTerminatedCodeUnits is retained as a span alongside it.
  • New "Path syntax versus filesystem interpretation" subsection in Path decomposition, covering the kernel-parses-syntax versus driver-interprets-opaque-bytes split that @jrose and @Joe_Groff asked about, contrasting .zfs/snapshots/<id> against Darwin's /.nofollow/.
1 Like