* Asynchronously renames file at `oldPath` to * the pathname provided as `newPath`. * @param {string | Buffer | URL} oldPath * @param {string | Buffer | URL} newPath * @param {(err?: Error) => any} callback * @returns {void}
(oldPath, newPath, callback)
| 1218 | * @returns {void} |
| 1219 | */ |
| 1220 | function rename(oldPath, newPath, callback) { |
| 1221 | const h = vfsState.handlers; |
| 1222 | if (h !== null && vfsVoid(h.rename(oldPath, newPath), callback)) return; |
| 1223 | |
| 1224 | callback = makeCallback(callback); |
| 1225 | const req = new FSReqCallback(); |
| 1226 | req.oncomplete = callback; |
| 1227 | binding.rename( |
| 1228 | getValidatedPath(oldPath, 'oldPath'), |
| 1229 | getValidatedPath(newPath, 'newPath'), |
| 1230 | req, |
| 1231 | ); |
| 1232 | } |
| 1233 | |
| 1234 | |
| 1235 | /** |
nothing calls this directly
no test coverage detected
searching dependent graphs…