* @param {string} [file]
(file)
| 254 | * @param {string} [file] |
| 255 | */ |
| 256 | reopen(file) { |
| 257 | if (this.#destroyed) { |
| 258 | throw new ERR_INVALID_STATE('Utf8Stream is destroyed'); |
| 259 | } |
| 260 | |
| 261 | if (this.#opening) { |
| 262 | this.once('ready', () => this.reopen(file)); |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | if (this.#ending) { |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | if (!this.#file) { |
| 271 | throw new ERR_OPERATION_FAILED( |
| 272 | 'Unable to reopen a file descriptor, you must pass a file to SonicBoom'); |
| 273 | } |
| 274 | |
| 275 | if (file) { |
| 276 | this.#file = file; |
| 277 | } |
| 278 | this.#reopening = true; |
| 279 | |
| 280 | if (this.#writing) { |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | const fd = this.#fd; |
| 285 | this.once('ready', () => { |
| 286 | if (fd !== this.#fd) { |
| 287 | this.#fs.close(fd, (err) => { |
| 288 | if (err) { |
| 289 | return this.emit('error', err); |
| 290 | } |
| 291 | }); |
| 292 | } |
| 293 | }); |
| 294 | |
| 295 | this.#openFile(this.#file); |
| 296 | } |
| 297 | |
| 298 | end() { |
| 299 | if (this.#destroyed) { |