(vfs)
| 53 | let vfsHandlerObj; |
| 54 | |
| 55 | function registerVFS(vfs) { |
| 56 | if (permission.isEnabled() && !getOptionValue('--allow-fs-vfs')) { |
| 57 | throw new ERR_INVALID_STATE( |
| 58 | 'VFS cannot be used when the permission model is enabled. ' + |
| 59 | 'Use --allow-fs-vfs to allow it.', |
| 60 | ); |
| 61 | } |
| 62 | if (ArrayPrototypeIndexOf(activeVFSList, vfs) !== -1) return; |
| 63 | |
| 64 | const newMount = vfs.mountPoint; |
| 65 | if (newMount != null) { |
| 66 | for (let i = 0; i < activeVFSList.length; i++) { |
| 67 | const existingMount = activeVFSList[i].mountPoint; |
| 68 | if (existingMount == null) continue; |
| 69 | // Use path.sep so the trailing-separator guard works on Windows where |
| 70 | // mountPoint values are resolved to drive-letter / backslash paths. |
| 71 | const newPrefix = newMount === sep ? sep : newMount + sep; |
| 72 | const existingPrefix = existingMount === sep ? sep : existingMount + sep; |
| 73 | if (newMount === existingMount || |
| 74 | StringPrototypeStartsWith(newMount, existingPrefix) || |
| 75 | StringPrototypeStartsWith(existingMount, newPrefix)) { |
| 76 | throw new ERR_INVALID_STATE( |
| 77 | `VFS mount '${newMount}' overlaps with existing mount '${existingMount}'`, |
| 78 | ); |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | ArrayPrototypePush(activeVFSList, vfs); |
| 83 | debug('register mount=%s active=%d', newMount, activeVFSList.length); |
| 84 | if (!hooksInstalled) { |
| 85 | vfsHandlerObj = createVfsHandlers(); |
| 86 | setVfsHandlers(vfsHandlerObj); |
| 87 | hooksInstalled = true; |
| 88 | } else if (vfsState.handlers === null) { |
| 89 | setVfsHandlers(vfsHandlerObj); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function deregisterVFS(vfs) { |
| 94 | const index = ArrayPrototypeIndexOf(activeVFSList, vfs); |
no test coverage detected
searching dependent graphs…