Path.replace

void replace(string target) const

Overwrites target by moving this path over it. On platforms that support it (POSIX), this is an atomic replacement using rename(2).

Platform semantics:

  • POSIX: Uses rename(2) which atomically replaces target if it exists.
  • Windows: Tries std.file.rename; if it fails due to an existing target,

removes the target and retries the rename. This may not be atomic.

This mirrors Python's pathlib Path.replace() behavior.

Parameters

targetThe destination path to be replaced by this path.