X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fdata%2Fmake-file.c;h=a1a541a5d0fb81c6c8938050ce6c3339f1ab31d5;hb=d8b3292a8c12564dbc67e59f24d626dcfbf2e274;hp=fdbb4643ebf7bb5e35ad219a81d4ad76f2384440;hpb=078b003b3171c6158a3419a01189b9658896f470;p=pspp diff --git a/src/data/make-file.c b/src/data/make-file.c index fdbb4643eb..a1a541a5d0 100644 --- a/src/data/make-file.c +++ b/src/data/make-file.c @@ -265,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)