* Truncates a file synchronously. * @param {string} filePath The file path * @param {number} [len] The new length
(filePath, len = 0)
| 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. |
no test coverage detected