X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fmake-file.c;h=a1a541a5d0fb81c6c8938050ce6c3339f1ab31d5;hb=bd5e8f74de87b9061ff62615f48fb378e844e87d;hp=78875746f24ea2ff99860c5af75825da78e60fe4;hpb=3dd0f6ae0d5eb73a2270a243e443c4ae03c2c16e;p=pspp diff --git a/src/data/make-file.c b/src/data/make-file.c index 78875746f2..a1a541a5d0 100644 --- a/src/data/make-file.c +++ b/src/data/make-file.c @@ -19,7 +19,6 @@ #include "data/make-file.h" #include "libpspp/i18n.h" -#include #include #include #include @@ -190,7 +189,7 @@ struct replace_file static struct ll_list all_files = LL_INITIALIZER (all_files); static void free_replace_file (struct replace_file *); -static void unlink_replace_files (void); +static void unlink_replace_files (int sig); struct replace_file * replace_file_start (const struct file_handle *fh, const char *mode, @@ -266,7 +265,10 @@ replace_file_start (const struct file_handle *fh, const char *mode, rf->tmp_name = convert_to_filename_encoding (rf->tmp_name_verbatim, strlen (rf->tmp_name_verbatim), fh_get_file_name_encoding (fh)); /* Create file by that name. */ - fd = Topen (rf->tmp_name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, permissions); + bool binary = strchr (mode, 'b') != NULL; + fd = Topen (rf->tmp_name, + O_WRONLY | O_CREAT | O_EXCL | (binary ? O_BINARY : O_TEXT), + permissions); if (fd >= 0) break; if (errno != EEXIST) @@ -370,7 +372,7 @@ free_replace_file (struct replace_file *rf) } static void -unlink_replace_files (void) +unlink_replace_files (int sig UNUSED) { struct replace_file *rf;