From a76d0cdf21c3d9e464623cc0ad1c005abf952afa Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Fri, 9 Aug 2013 10:58:15 +0300 Subject: libavutil: Move avpriv_open to a new file, file_open.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavutil/file.c | 64 -------------------------------------------------------- 1 file changed, 64 deletions(-) (limited to 'libavutil/file.c') diff --git a/libavutil/file.c b/libavutil/file.c index cf76a8ac82..d2765b8490 100644 --- a/libavutil/file.c +++ b/libavutil/file.c @@ -21,7 +21,6 @@ #include "internal.h" #include "log.h" #include "mem.h" -#include #include #include #if HAVE_UNISTD_H @@ -36,69 +35,6 @@ #include #endif -#if defined(_WIN32) && !defined(__MINGW32CE__) -#undef open -#undef lseek -#undef stat -#undef fstat -#include -#include -#include - -static int 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, MB_ERR_INVALID_CHARS, filename_utf8, -1, NULL, 0); - if (num_chars <= 0) - goto fallback; - filename_w = av_mallocz(sizeof(wchar_t) * num_chars); - if (!filename_w) { - errno = ENOMEM; - 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); - - if (fd != -1 || (oflag & O_CREAT)) - return fd; - -fallback: - /* filename may be be in CP_ACP */ - return _sopen(filename_utf8, oflag, SH_DENYNO, pmode); -} -#define open win32_open -#endif - -int avpriv_open(const char *filename, int flags, ...) -{ - int fd; - unsigned int mode = 0; - va_list ap; - - va_start(ap, flags); - if (flags & O_CREAT) - mode = va_arg(ap, unsigned int); - va_end(ap); - -#ifdef O_CLOEXEC - flags |= O_CLOEXEC; -#endif - - fd = open(filename, flags, mode); -#if HAVE_FCNTL - if (fd != -1) - fcntl(fd, F_SETFD, FD_CLOEXEC); -#endif - - return fd; -} - typedef struct { const AVClass *class; int log_offset; -- cgit v1.2.3