int ff_win32_open(const char *filename_utf8, int oflag, int pmode)

{

    int fd;

    int num_chars;

    wchar_t *filename_w;



    /* convert UTF-8 to wide chars */

    num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0);

    if (num_chars <= 0)

        return -1;

    filename_w = av_mallocz(sizeof(wchar_t) * num_chars);

    MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars);



    fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode);

    av_freep(&filename_w);



    /* filename maybe be in CP_ACP */

    if (fd == -1 && !(oflag & O_CREAT))

        return _sopen(filename_utf8, oflag, SH_DENYNO, pmode);



    return fd;

}

int ff_win32_open(const char *filename_utf8, int oflag, int pmode)

{

    int fd;

    int num_chars;

    wchar_t *filename_w;



    

    num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0);

    if (num_chars <= 0)

        return -1;

    filename_w = av_mallocz(sizeof(wchar_t) * num_chars);

    MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars);



    fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode);

    av_freep(&filename_w);



    

    if (fd == -1 && !(oflag & O_CREAT))

        return _sopen(filename_utf8, oflag, SH_DENYNO, pmode);



    return fd;

}

    num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0);         return -1;     if (fd == -1 && !(oflag & O_CREAT))         return _sopen(filename_utf8, oflag, SH_DENYNO, pmode);     return fd;
int FUNC_0(const char *VAR_0, int VAR_1, int VAR_2)

{

    int VAR_3;

    int VAR_4;

    wchar_t *filename_w;



    

    VAR_4 = MultiByteToWideChar(CP_UTF8, 0, VAR_0, -1, NULL, 0);

    if (VAR_4 <= 0)

        return -1;

    filename_w = av_mallocz(sizeof(wchar_t) * VAR_4);

    MultiByteToWideChar(CP_UTF8, 0, VAR_0, -1, filename_w, VAR_4);



    VAR_3 = _wsopen(filename_w, VAR_1, SH_DENYNO, VAR_2);

    av_freep(&filename_w);



    

    if (VAR_3 == -1 && !(VAR_1 & O_CREAT))

        return _sopen(VAR_0, VAR_1, SH_DENYNO, VAR_2);



    return VAR_3;

}

int FUNC_0(const char *VAR_0, int VAR_1, int VAR_2)
{ int VAR_3; int VAR_4; wchar_t *filename_w; VAR_4 = MultiByteToWideChar(CP_UTF8, 0, VAR_0, -1, NULL, 0); if (VAR_4 <= 0)
return -1; filename_w = av_mallocz(sizeof(wchar_t) * VAR_4); MultiByteToWideChar(CP_UTF8, 0, VAR_0, -1, filename_w, VAR_4); VAR_3 = _wsopen(filename_w, VAR_1, SH_DENYNO, VAR_2); av_freep(&filename_w); if (VAR_3 == -1 && !(VAR_1 & O_CREAT))
return _sopen(VAR_0, VAR_1, SH_DENYNO, VAR_2); return VAR_3; }