atomicMove

abstract fun atomicMove(source: Path, destination: Path)(source)

Atomically renames source to destination overriding destination if it already exists.

When the filesystem does not support atomic move of source and destination corresponds to different filesystems (or different volumes, on Windows) and the operation could not be performed atomically, UnsupportedOperationException is thrown.

On some platforms, like Wasm-WASI, there is no way to tell if the underlying filesystem supports atomic move. In such cases, the move will be performed and no UnsupportedOperationException will be thrown.

When destination is an existing directory, the operation may fail on some platforms (on Windows, particularly).

Parameters

source

the path to rename.

destination

desired path name.

Throws

when the source does not exist.

when the move failed.

when the filesystem does not support atomic move.