* Synchronously truncates the file. * @param {string | Buffer | URL} path * @param {number} [len] * @returns {void}
(path, len)
| 1292 | * @returns {void} |
| 1293 | */ |
| 1294 | function truncateSync(path, len) { |
| 1295 | if (len === undefined) { |
| 1296 | len = 0; |
| 1297 | } |
| 1298 | |
| 1299 | const h = vfsState.handlers; |
| 1300 | if (h !== null) { |
| 1301 | const result = h.truncateSync(path, len); |
| 1302 | if (result !== undefined) return; |
| 1303 | } |
| 1304 | |
| 1305 | // Allow error to be thrown, but still close fd. |
| 1306 | const fd = fs.openSync(path, 'r+'); |
| 1307 | try { |
| 1308 | fs.ftruncateSync(fd, len); |
| 1309 | } finally { |
| 1310 | fs.closeSync(fd); |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | /** |
| 1315 | * Truncates the file descriptor. |
nothing calls this directly
no test coverage detected
searching dependent graphs…