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

Method truncateSync

lib/internal/vfs/file_system.js:464–473  ·  view source on GitHub ↗

* Truncates a file synchronously. * @param {string} filePath The file path * @param {number} [len] The new length

(filePath, len = 0)

Source from the content-addressed store, hash-verified

462 * @param {number} [len] The new length
463 */
464 truncateSync(filePath, len = 0) {
465 if (len < 0) len = 0;
466 const providerPath = this.#toProviderPath(filePath);
467 const handle = this[kProvider].openSync(providerPath, 'r+');
468 try {
469 handle.truncateSync(len);
470 } finally {
471 handle.closeSync();
472 }
473 }
474
475 /**
476 * Truncates a file descriptor synchronously.

Callers 2

truncateMethod · 0.95
ftruncateSyncMethod · 0.45

Calls 3

#toProviderPathMethod · 0.95
openSyncMethod · 0.45
closeSyncMethod · 0.45

Tested by

no test coverage detected