X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fmsglog.c;h=0d0329571045daa79b48190e3a22b1600250f9c7;hb=58c0ae54e9ff110922aa41bb51c82baa9fb0bb3b;hp=a3f195410406b70c6f18c00d57578d9cf6cf8fd6;hpb=e2da62d735c597afeef2e0e9b36e5a4a83d7da94;p=pspp diff --git a/src/output/msglog.c b/src/output/msglog.c index a3f1954104..0d03295710 100644 --- a/src/output/msglog.c +++ b/src/output/msglog.c @@ -24,6 +24,7 @@ #include #include "data/file-name.h" +#include "data/file-handle-def.h" #include "data/settings.h" #include "libpspp/cast.h" #include "libpspp/message.h" @@ -40,7 +41,7 @@ struct msglog_driver { struct output_driver driver; FILE *file; - char *file_name; + struct file_handle *handle; char *command_name; }; @@ -60,7 +61,9 @@ msglog_create (const char *file_name) struct msglog_driver *ml; FILE *file; - file = fn_open (file_name, "w"); + struct file_handle *handle = fh_create_file (NULL, file_name, NULL, fh_default_properties ()); + + file = fn_open (handle, "w"); if (file == NULL) { msg_error (errno, _("error opening output file `%s'"), file_name); @@ -72,9 +75,9 @@ msglog_create (const char *file_name) : SETTINGS_DEVICE_UNFILTERED); ml = xzalloc (sizeof *ml); + ml->handle = handle; output_driver_init (&ml->driver, &msglog_class, file_name, type); ml->file = file; - ml->file_name = xstrdup (file_name); ml->command_name = NULL; output_driver_register (&ml->driver); @@ -87,9 +90,9 @@ msglog_destroy (struct output_driver *driver) { struct msglog_driver *ml = msglog_driver_cast (driver); - fn_close (ml->file_name, ml->file); - free (ml->file_name); + fn_close (ml->handle, ml->file); free (ml->command_name); + fh_unref (ml->handle); free (ml); }