summaryrefslogtreecommitdiff
path: root/libavformat/os_support.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/os_support.c')
-rw-r--r--libavformat/os_support.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 1ecf43c3dc..0a901f6bd2 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -3,20 +3,20 @@
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
* copyright (c) 2002 Francois Revol
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -29,6 +29,9 @@
#if defined(_WIN32) && !defined(__MINGW32CE__)
#undef open
+#undef lseek
+#undef stat
+#undef fstat
#include <fcntl.h>
#include <io.h>
#include <windows.h>
@@ -41,20 +44,23 @@ int ff_win32_open(const char *filename_utf8, int oflag, int pmode)
wchar_t *filename_w;
/* convert UTF-8 to wide chars */
- num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0);
+ num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename_utf8, -1, NULL, 0);
if (num_chars <= 0)
- return -1;
+ goto fallback;
filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
+ if (!filename_w)
+ return -1;
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);
+ if (fd != -1 || (oflag & O_CREAT))
+ return fd;
- return fd;
+fallback:
+ /* filename maybe be in CP_ACP */
+ return _sopen(filename_utf8, oflag, SH_DENYNO, pmode);
}
#endif