(source, destination, cb)
| 774 | }, |
| 775 | |
| 776 | rename(source, destination, cb) { |
| 777 | try { |
| 778 | if (isPendingCreate(source)) { |
| 779 | // Source hasn't been persisted yet, so there's nothing for |
| 780 | // the VFS to move. POSIX rename(2) overwrites a regular file |
| 781 | // at the destination; honour that here by unlinking any |
| 782 | // pre-existing destination inode and dropping any pending |
| 783 | // entry that was staged at it. The next flush of the |
| 784 | // remapped buffer will create the dest inode fresh. |
| 785 | const destPending = isPendingCreate(destination); |
| 786 | if (!destPending && vfs.existsSync(toVfs(destination))) { |
| 787 | vfs.unlinkSync(toVfs(destination)); |
| 788 | } |
| 789 | if (destPending) { |
| 790 | files.delete(destination); |
| 791 | } |
| 792 | meta.delete(destination); |
| 793 | } else { |
| 794 | vfs.renameSync(toVfs(source), toVfs(destination)); |
| 795 | } |
| 796 | const m = meta.get(source); |
| 797 | if (m !== undefined) { |
| 798 | meta.delete(source); |
| 799 | meta.set(destination, m); |
| 800 | } |
| 801 | const entry = files.get(source); |
| 802 | if (entry !== undefined) { |
| 803 | files.delete(source); |
| 804 | files.set(destination, entry); |
| 805 | } |
| 806 | cb(0); |
| 807 | } catch (error) { |
| 808 | cb(toErrno(error)); |
| 809 | } |
| 810 | }, |
| 811 | |
| 812 | access(path, mode, cb) { |
| 813 | try { |
nothing calls this directly
no test coverage detected