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

Method constructor

lib/internal/vfs/file_handle.js:379–400  ·  view source on GitHub ↗

* @param {string} path The file path * @param {string} flags The open flags * @param {number} [mode] The file mode * @param {Buffer} content The initial file content * @param {object} entry The entry object (for updating content) * @param {Function} getStats Function to get updated st

(path, flags, mode, content, entry, getStats)

Source from the content-addressed store, hash-verified

377 * @param {Function} getStats Function to get updated stats
378 */
379 constructor(path, flags, mode, content, entry, getStats) {
380 super(path, flags, mode);
381 this.#content = content;
382 this.#size = content.length;
383 this.#entry = entry;
384 this.#getStats = getStats;
385
386 // Handle different open modes
387 if (flags === 'w' || flags === 'w+' ||
388 flags === 'wx' || flags === 'wx+') {
389 // Write mode: truncate
390 this.#content = Buffer.alloc(0);
391 this.#size = 0;
392 if (entry) {
393 entry.content = this.#content;
394 }
395 } else if (flags === 'a' || flags === 'a+' ||
396 flags === 'ax' || flags === 'ax+') {
397 // Append mode: position at end
398 this.position = this.#size;
399 }
400 }
401
402 /**
403 * Throws EBADF if the handle was not opened for writing.

Callers

nothing calls this directly

Calls 1

allocMethod · 0.80

Tested by

no test coverage detected