Deno.renamesync
renameSync
-
renameSync(oldpath: string, newpath: string): void
-
同步方式将
oldpath
重命名(或移动)为newpath
。路径可以是文件或目录。 如果newpath
已经存在且不是目录,那么rename()
将替换它。 当oldpath
和newpath
位于不同的目录中时,可能会受到操作系统的限制。Synchronously renames (moves)
oldpath
tonewpath
. Paths may be files or directories. Ifnewpath
already exists and is not a directory,renameSync()
replaces it. OS-specific restrictions may apply whenoldpath
andnewpath
are in different directories.Deno.renameSync("old/path", "new/path");
在 Unix 系统上,此操作不会修改符号链接所指向的内容。
On Unix, this operation does not follow symlinks at either path.
当操作引发错误时,平台之间会有所不同。 如果
newpath
是非空目录则始终会报错。It varies between platforms when the operation throws errors, and if so what they are. It’s always an error to rename anything to a non-empty directory.
需要
allow-read
和allow-write
权限。Requires
allow-read
andallow-write
permissions.
参数
- ##### oldpath: string
- ##### newpath: string