mode = S_IRUSR | S_IRGRP | S_IROTH;
if (opts.create_writeable)
mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- fd = open (handle_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
+ fd = open (fh_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
if (fd < 0)
goto open_error;
/* Open file handle. */
- if (!fh_open (fh, "system file", "we"))
+ if (!fh_open (fh, FH_REF_FILE, "system file", "we"))
goto error;
/* Create and initialize writer. */
open_error:
msg (ME, _("Error opening \"%s\" for writing as a system file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (fh), strerror (errno));
err_cond_fail ();
goto error;
}
if (fwrite (buf, nbytes, 1, w->file) != 1)
{
msg (ME, _("%s: Writing system file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
return 0;
}
return 1;
/* Writes case C to system file W.
Returns nonzero if successful. */
int
-sfm_write_case (struct sfm_writer *w, struct ccase *c)
+sfm_write_case (struct sfm_writer *w, const struct ccase *c)
{
w->case_cnt++;
if (w == NULL)
return;
- fh_close (w->fh, "system file", "we");
-
if (w->file != NULL)
{
/* Flush buffer. */
if (fclose (w->file) == EOF)
msg (ME, _("%s: Closing system file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
}
+ fh_close (w->fh, "system file", "we");
+
free (w->buf);
free (w->vars);
free (w);