On 6 June 2016 at 19:27, Hendrik Leppkes <h.lepp...@gmail.com> wrote:

> On Mon, Jun 6, 2016 at 9:12 AM, Matt Oliver <protogo...@gmail.com> wrote:
> > Fixes #819 #5256 #5281
> > ---
> >  libavformat/file.c       |  4 ++++
> >  libavformat/os_support.h | 24 ++++++++++++++++++++++++
> >  2 files changed, 28 insertions(+)
> >
> > diff --git a/libavformat/file.c b/libavformat/file.c
> > index 5765ce7..264542a 100644
> > --- a/libavformat/file.c
> > +++ b/libavformat/file.c
> > @@ -148,7 +148,11 @@ static int file_check(URLContext *h, int mask)
> >              ret |= AVIO_FLAG_WRITE;
> >  #else
> >      struct stat st;
> > +#   ifndef _WIN32
> >      ret = stat(filename, &st);
> > +#   else
> > +    ret = win32_stat(filename, &st);
> > +#   endif
>
> Isn't the typical way to define stat to win32_stat in the os_support
> header, instead of ifdefing here?
>

No as there is a stat struct type as well as the stat function so a define
cannot be used for the function as it will mess with the stat struct. Hence
why the only way to get around it was to manually call the appropriate
win32 function.


>
> >      if (ret < 0)
> >          return AVERROR(errno);
> >
> > diff --git a/libavformat/os_support.h b/libavformat/os_support.h
> > index a332911..9e312a5 100644
> > --- a/libavformat/os_support.h
> > +++ b/libavformat/os_support.h
> > @@ -182,6 +182,29 @@ DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
> >  DEF_FS_FUNCTION(mkdir,  _wmkdir,  _mkdir)
> >  DEF_FS_FUNCTION(rmdir,  _wrmdir , _rmdir)
> >
> > +#define DEF_FS_FUNCTION2(name, wfunc, afunc, partype)     \
> > +static inline int win32_##name(const char *filename_utf8, partype par) \
> > +{                                                         \
> > +    wchar_t *filename_w;                                  \
> > +    int ret;                                              \
> > +                                                          \
> > +    if (utf8towchar(filename_utf8, &filename_w))          \
> > +        return -1;                                        \
> > +    if (!filename_w)                                      \
> > +        goto fallback;                                    \
> > +                                                          \
> > +    ret = wfunc(filename_w, par);                         \
> > +    av_free(filename_w);                                  \
> > +    return ret;                                           \
> > +                                                          \
> > +fallback:                                                 \
> > +    /* filename may be be in CP_ACP */                    \
> > +    return afunc(filename_utf8, par);                     \
> > +}
> > +
> > +DEF_FS_FUNCTION2(access, _waccess, _access, int)
> > +DEF_FS_FUNCTION2(stat, _wstat64, _stat64, struct stat*)
> > +
> >  static inline int win32_rename(const char *src_utf8, const char
> *dest_utf8)
> >  {
> >      wchar_t *src_w, *dest_w;
> > @@ -231,6 +254,7 @@ fallback:
> >  #define rename      win32_rename
> >  #define rmdir       win32_rmdir
> >  #define unlink      win32_unlink
> > +#define access      win32_access
> >
> >  #endif
> >
> > --
> > 2.8.1.windows.1
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to