summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Smith <msmith@songbirdnest.com>2009-10-07 16:02:58 -0700
committerMichael Smith <msmith@songbirdnest.com>2009-10-07 16:03:30 -0700
commit0c3a8165b69294cd55839c692efd7cb7d144b370 (patch)
tree54b498bc30a53d8502a4f912f7bbcffdef73c07f
parent07d953b791fd0de1ce57d5505fe08e8edeb105e6 (diff)
filesink: Use _wfopen on win32 to open files with non-ascii filenames correctly.
-rw-r--r--plugins/elements/gstfilesink.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c
index 26fa1ea910..d2ad8b594d 100644
--- a/plugins/elements/gstfilesink.c
+++ b/plugins/elements/gstfilesink.c
@@ -102,6 +102,44 @@ enum
PROP_LAST
};
+/* Copy of glib's g_fopen due to win32 libc/cross-DLL brokenness: we can't
+ * use the 'file pointer' opened in glib (and returned from this function)
+ * in this library, as they may have unrelated C runtimes. */
+FILE *
+gst_fopen (const gchar * filename, const gchar * mode)
+{
+#ifdef G_OS_WIN32
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ wchar_t *wmode;
+ FILE *retval;
+ int save_errno;
+
+ if (wfilename == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
+
+ if (wmode == NULL) {
+ g_free (wfilename);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ retval = _wfopen (wfilename, wmode);
+ save_errno = errno;
+
+ g_free (wfilename);
+ g_free (wmode);
+
+ errno = save_errno;
+ return retval;
+#else
+ return fopen (filename, mode);
+#endif
+}
+
static void gst_file_sink_dispose (GObject * object);
static void gst_file_sink_set_property (GObject * object, guint prop_id,
@@ -334,13 +372,10 @@ gst_file_sink_open_file (GstFileSink * sink)
if (sink->filename == NULL || sink->filename[0] == '\0')
goto no_filename;
- /* FIXME, can we use g_fopen here? some people say that the FILE object is
- * local to the .so that performed the fopen call, which would not be us when
- * we use g_fopen. */
if (sink->append)
- sink->file = fopen (sink->filename, "ab");
+ sink->file = gst_fopen (sink->filename, "ab");
else
- sink->file = fopen (sink->filename, "wb");
+ sink->file = gst_fopen (sink->filename, "wb");
if (sink->file == NULL)
goto open_failed;