[FFmpeg-devel] [PATCH] Allow other programs to open the same files on Windows.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Jan 20 20:28:47 CET 2012


In order to match Linux behaviour better our
Windows-specific open() replacement should disable
Windows default file locking.
Patch is completely untested.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavformat/os_support.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 467053e..8d93be9 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -29,6 +29,7 @@
 
 #if defined(_WIN32) && !defined(__MINGW32CE__)
 #include <windows.h>
+#include <share.h>
 
 #undef open
 int ff_win32_open(const char *filename_utf8, int oflag, int pmode)
@@ -44,12 +45,12 @@ int ff_win32_open(const char *filename_utf8, int oflag, int pmode)
     filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
     MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars);
 
-    fd = _wopen(filename_w, oflag, pmode);
+    fd = _wsopen(filename_w, oflag, pmode, SH_DENYNO);
     av_freep(&filename_w);
 
     /* filename maybe be in CP_ACP */
     if (fd == -1 && !(oflag & O_CREAT))
-        return open(filename_utf8, oflag, pmode);
+        return _sopen(filename_utf8, oflag, pmode, SH_DENYNO);
 
     return fd;
 }
-- 
1.7.8.3



More information about the ffmpeg-devel mailing list