time-to-botec/squiggle/node_modules/@stdlib/fs/rename/docs/repl.txt
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

81 lines
2.5 KiB
Plaintext

{{alias}}( oldPath, newPath, clbk )
Asynchronously renames a file.
The old path can specify a directory. In this case, the new path must either
not exist, or it must specify an empty directory.
The old pathname should not name an ancestor directory of the new pathname.
If the old path points to the pathname of a file that is not a directory,
the new path should not point to the pathname of a directory.
Write access permission is required for both the directory containing the
old path and the directory containing the new path.
If the link named by the new path exists, the new path is removed and the
old path is renamed to the new path. The link named by the new path will
remain visible to other threads throughout the renaming operation and refer
to either the file referred to by the new path or to the file referred to by
the old path before the operation began.
If the old path and the new path resolve to either the same existing
directory entry or to different directory entries for the same existing
file, no action is taken, and no error is returned.
If the old path points to a pathname of a symbolic link, the symbolic link
is renamed. If the new path points to a pathname of a symbolic link, the
symbolic link is removed.
If a link named by the new path exists and the file's link count becomes 0
when it is removed and no process has the file open, the space occupied by
the file is freed and the file is no longer accessible. If one or more
processes have the file open when the last link is removed, the link is
removed before the function returns, but the removal of file contents is
postponed until all references to the file are closed.
Parameters
----------
oldPath: string|Buffer
Old path.
newPath: string|Buffer
New path.
clbk: Function
Callback to invoke upon renaming a file.
Examples
--------
> function done( error ) {
... if ( error ) {
... console.error( error.message );
... }
... };
> {{alias}}( './beep/boop.txt', './beep/foo.txt', done );
{{alias}}.sync( oldPath, newPath )
Synchronously renames a file.
Parameters
----------
oldPath: string|Buffer
Old path.
newPath: string|Buffer
New path.
Returns
-------
err: Error|null
Error object or null.
Examples
--------
> var err = {{alias}}.sync( './beep/boop.txt', './beep/foo.txt' );
See Also
--------