aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-10 10:36:18 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-10 10:37:20 +0200
commitef13a005c41c353b03b29edf7a20d226747dac4e (patch)
treedb2ab0666a1a38a397fa056c8f0a825e1d75f29c
parente3a296dfa53ba78360d7f2c8c931db3490b06d5b (diff)
parenta76d0cdf21c3d9e464623cc0ad1c005abf952afa (diff)
downloadffmpeg-ef13a005c41c353b03b29edf7a20d226747dac4e.tar.gz
Merge commit 'a76d0cdf21c3d9e464623cc0ad1c005abf952afa'
* commit 'a76d0cdf21c3d9e464623cc0ad1c005abf952afa': libavutil: Move avpriv_open to a new file, file_open.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavutil/Makefile1
-rw-r--r--libavutil/file.c64
-rw-r--r--libavutil/file_open.c93
3 files changed, 94 insertions, 64 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 21746f0713..50067672c9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -81,6 +81,7 @@ OBJS = adler32.o \
eval.o \
fifo.o \
file.o \
+ file_open.o \
float_dsp.o \
frame.o \
hash.o \
diff --git a/libavutil/file.c b/libavutil/file.c
index 407941cd58..45fe8538de 100644
--- a/libavutil/file.c
+++ b/libavutil/file.c
@@ -21,7 +21,6 @@
#include "internal.h"
#include "log.h"
#include "mem.h"
-#include <stdarg.h>
#include <fcntl.h>
#include <sys/stat.h>
#if HAVE_UNISTD_H
@@ -36,69 +35,6 @@
#include <windows.h>
#endif
-#if defined(_WIN32) && !defined(__MINGW32CE__)
-#undef open
-#undef lseek
-#undef stat
-#undef fstat
-#include <windows.h>
-#include <share.h>
-#include <errno.h>
-
-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;
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
new file mode 100644
index 0000000000..8a65117265
--- /dev/null
+++ b/libavutil/file_open.c
@@ -0,0 +1,93 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * 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.
+ *
+ * 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "internal.h"
+#include "mem.h"
+#include <stdarg.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_IO_H
+#include <io.h>
+#endif
+
+#if defined(_WIN32) && !defined(__MINGW32CE__)
+#undef open
+#undef lseek
+#undef stat
+#undef fstat
+#include <windows.h>
+#include <share.h>
+#include <errno.h>
+
+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;
+}