-/* Writes BYTES bytes from BUFFER into TF's underlying file.
- TF must not be tainted upon entry into this function.
- Returns true if successful, false upon an I/O error (in which
- case TF is marked tainted). */
-static bool
-do_write (struct temp_file *tf, const void *buffer, size_t bytes)
-{
- assert (!temp_file_error (tf));
- if (bytes > 0 && fwrite (buffer, bytes, 1, tf->file) != 1)
- {
- error (0, errno, _("writing to temporary file"));
- return false;
- }
- tf->position += bytes;
- return true;
-}
+ file_name = xasprintf ("%s/%d", temp_dir->dir_name, idx++);
+ register_temp_file (temp_dir, file_name);
+ stream = fopen_temp (file_name, "wb+");
+ if (stream == NULL)
+ unregister_temp_file (temp_dir, file_name);
+ else
+ setvbuf (stream, NULL, _IOFBF, 65536);