Path.drive

string drive() const @safe

Return the drive component of the path (Windows only).

Semantics (Windows):

  • Drive-letter paths: "C:" for both absolute ("C:\\...") and drive-relative ("C:foo").
  • UNC paths: "\\\\server\\share".
  • Root-only paths like "\\foo" have an empty drive.

Returns

The drive string, or an empty string on non-Windows platforms or when the path has no drive.