MCPcopy Index your code
hub / github.com/nodejs/node / registerVFS

Function registerVFS

lib/internal/vfs/setup.js:55–91  ·  view source on GitHub ↗
(vfs)

Source from the content-addressed store, hash-verified

53let vfsHandlerObj;
54
55function 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
93function deregisterVFS(vfs) {
94 const index = ArrayPrototypeIndexOf(activeVFSList, vfs);

Callers 1

mountMethod · 0.85

Calls 5

getOptionValueFunction · 0.85
createVfsHandlersFunction · 0.85
setVfsHandlersFunction · 0.85
isEnabledMethod · 0.80
debugFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…