Atom

fs.copy()

Copies a file.

Signature

fs.copy(source, destination[, overwrite])

Parameters

Two paths and optional boolean overwrite, default false.

Returns

Null.

Behavior

Creates or replaces destination subject to the flag.

Errors

Existing destination without overwrite, invalid paths or OS failure.

Example

Atom
use fs
use path
p = fs.temporary_directory()
a = path.join(p, 'a')
b = path.join(p, 'b')
write(a, 'Atom')
fs.copy(a, b)
assert(read(b) == 'Atom')
fs.remove(p, true)