* Writes a file synchronously. * @param {string} path The file path * @param {Buffer|string} data The data to write * @param {object} [options] Options
(path, data, options)
| 298 | * @param {object} [options] Options |
| 299 | */ |
| 300 | writeFileSync(path, data, options) { |
| 301 | if (this.readonly) { |
| 302 | throw createEROFS('open', path); |
| 303 | } |
| 304 | const flag = options?.flag ?? 'w'; |
| 305 | const handle = this.openSync(path, flag, options?.mode); |
| 306 | try { |
| 307 | handle.writeFileSync(data, options); |
| 308 | } finally { |
| 309 | handle.closeSync(); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * Appends to a file. |