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

Function ftruncate

lib/fs.js:1321–1336  ·  view source on GitHub ↗

* Truncates the file descriptor. * @param {number} fd * @param {number} [len] * @param {(err?: Error) => any} callback * @returns {void}

(fd, len = 0, callback)

Source from the content-addressed store, hash-verified

1319 * @returns {void}
1320 */
1321function ftruncate(fd, len = 0, callback) {
1322 if (typeof len === 'function') {
1323 callback = len;
1324 len = 0;
1325 }
1326 validateInteger(len, 'len');
1327 len = MathMax(0, len);
1328 callback = makeCallback(callback);
1329
1330 const h = vfsState.handlers;
1331 if (h !== null && vfsVoid(h.ftruncate(fd, len), callback)) return;
1332
1333 const req = new FSReqCallback();
1334 req.oncomplete = callback;
1335 binding.ftruncate(fd, len, req);
1336}
1337
1338/**
1339 * Synchronously truncates the file descriptor.

Callers

nothing calls this directly

Calls 3

vfsVoidFunction · 0.85
ftruncateMethod · 0.80
makeCallbackFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…