[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ios: open files in binary mode on windows
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] ios: open files in binary mode on windows |
Date: |
Tue, 20 Feb 2024 20:28:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Hannes.
Isn't this something to do only ifdef _WIN32?
> 2024-02-18 Hannes Domani <ssbssa@yahoo.de>
>
> * libpoke/ios-dev-file.c (O_BINARY): Define if it doesn't exist.
> (ios_dev_file_open): Open files in binary mode.
> ---
> libpoke/ios-dev-file.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/libpoke/ios-dev-file.c b/libpoke/ios-dev-file.c
> index 62820082..d1fffff0 100644
> --- a/libpoke/ios-dev-file.c
> +++ b/libpoke/ios-dev-file.c
> @@ -32,6 +32,10 @@
> #include "ios.h"
> #include "ios-dev.h"
>
> +#ifndef O_BINARY
> +#define O_BINARY 0
> +#endif
> +
> /* State associated with a file device. */
>
> struct ios_dev_file
> @@ -118,7 +122,8 @@ ios_dev_file_open (const char *handler, uint64_t flags,
> int *error,
> internal_error = IOD_EFLAGS;
> goto err;
> }
> - fd = open (handler, flags_for_open, S_IRUSR | S_IWUSR | S_IRGRP |
> S_IROTH);
> + fd = open (handler, flags_for_open | O_BINARY,
> + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
> if (fd == -1)
> goto err;
> f = fdopen (fd, mode_for_fdopen);
> @@ -130,19 +135,19 @@ ios_dev_file_open (const char *handler, uint64_t flags,
> int *error,
> If that fails, then try write-only. */
> const char *mode_for_fdopen;
>
> - fd = open (handler, O_RDWR, 0);
> + fd = open (handler, O_RDWR | O_BINARY, 0);
> flags |= (IOS_F_READ | IOS_F_WRITE);
> mode_for_fdopen = "r+b";
> if (fd == -1)
> {
> - fd = open (handler, O_RDONLY, 0);
> + fd = open (handler, O_RDONLY | O_BINARY, 0);
> if (fd != -1)
> flags &= ~IOS_F_WRITE;
> mode_for_fdopen = "rb";
> }
> if (fd == -1)
> {
> - fd = open (handler, O_WRONLY, 0);
> + fd = open (handler, O_WRONLY | O_BINARY, 0);
> if (fd != -1)
> flags &= ~IOS_F_READ;
> mode_for_fdopen = "wb";