poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] ios: open files in binary mode on windows


From: Hannes Domani
Subject: Re: [PATCH v2] ios: open files in binary mode on windows
Date: Thu, 22 Feb 2024 15:25:34 +0000 (UTC)

 Am Mittwoch, 21. Februar 2024 um 20:52:24 MEZ hat Mohammad-Reza Nabipoor 
<mnabipoor@gnu.org> Folgendes geschrieben:

> Hi Hannes,
>
> On Wed, Feb 21, 2024 at 05:53:08PM +0100, Hannes Domani via poke-devel wrote:
> > 2024-02-21  Hannes Domani  <ssbssa@yahoo.de>
> >
> >     * libpoke/ios-dev-file.c (ios_dev_file_open): Open files in
> >     binary mode on windows.
> > ---
> >  libpoke/ios-dev-file.c | 17 +++++++++++++----
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/libpoke/ios-dev-file.c b/libpoke/ios-dev-file.c
> > index 62820082..63074f8c 100644
> > --- a/libpoke/ios-dev-file.c
> > +++ b/libpoke/ios-dev-file.c
> > @@ -108,6 +108,14 @@ ios_dev_file_open (const char *handler, uint64_t 
> > flags, int *error,
> >    int flags_for_open = 0;
> >    int fd;
> >
> > +#ifdef _WIN32
> > +  /* On windows the O_BINARY flag is needed to open files in binary mode.  
> > */
> > +  int bin_flag = O_BINARY;
> > +#else
> > +  /* For other targets use 0 to keep the original flags.  */
> > +  int bin_flag = 0;
> > +#endif
> > +
>
>
> What about something like this:
>
> ```c
> #ifdef _WIN32
> #define PLATFORM_FLAGS_FOR_OPEN O_BINARY
> #else
> #define PLATFORM_FLAGS_FOR_OPEN 0
> #endif
> ```
>
>
> >    if (mode_flags != 0)
> >      {
>
>
> And at the end of `else` branch, you add
>
> ```c
> #undef PLATFORM_FLAGS_FOR_OPEN
> ```
>
>
> What do you think?

I would never do it like that, but if you prefer it this way, ok?


Hannes


reply via email to

[Prev in Thread] Current Thread [Next in Thread]