* Writes a file. * @param {string} path The file path * @param {Buffer|string} data The data to write * @param {object} [options] Options * @returns {Promise }
(path, data, options)
| 279 | * @returns {Promise<void>} |
| 280 | */ |
| 281 | async writeFile(path, data, options) { |
| 282 | if (this.readonly) { |
| 283 | throw createEROFS('open', path); |
| 284 | } |
| 285 | const flag = options?.flag ?? 'w'; |
| 286 | const handle = await this.open(path, flag, options?.mode); |
| 287 | try { |
| 288 | await handle.writeFile(data, options); |
| 289 | } finally { |
| 290 | await handle.close(); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * Writes a file synchronously. |
no test coverage detected