[glib] gfileutils: Remove old win32 codepage ABI compat code



commit d1528402ab15bb174e0cf02e4fdbb9115eeb8b3a
Author: Christoph Reiter <creiter src gnome org>
Date:   Tue Mar 28 08:01:43 2017 +0200

    gfileutils: Remove old win32 codepage ABI compat code
    
    Makes new code link against the normal symbol names again.
    Variants with utf8 suffix are there for existing binaries/ABI compat.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780634

 glib/gfileutils.c |  115 +++++++++++++---------------------------------------
 glib/gfileutils.h |   27 ------------
 2 files changed, 29 insertions(+), 113 deletions(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index daac6ed..40775e2 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -2515,114 +2515,57 @@ g_get_current_dir (void)
 #endif /* !G_OS_WIN32 */
 }
 
+#ifdef G_OS_WIN32
 
-/* NOTE : Keep this part last to ensure nothing in this file uses thn
- * below binary compatibility versions.
- */
-#if defined (G_OS_WIN32) && !defined (_WIN64)
+/* Binary compatibility versions. Not for newly compiled code. */
 
-/* Binary compatibility versions. Will be called by code compiled
- * against quite old (pre-2.8, I think) headers only, not from more
- * recently compiled code.
- */
+_GLIB_EXTERN gboolean g_file_test_utf8         (const gchar  *filename,
+                                                GFileTest     test);
+_GLIB_EXTERN gboolean g_file_get_contents_utf8 (const gchar  *filename,
+                                                gchar       **contents,
+                                                gsize        *length,
+                                                GError      **error);
+_GLIB_EXTERN gint     g_mkstemp_utf8           (gchar        *tmpl);
+_GLIB_EXTERN gint     g_file_open_tmp_utf8     (const gchar  *tmpl,
+                                                gchar       **name_used,
+                                                GError      **error);
+_GLIB_EXTERN gchar   *g_get_current_dir_utf8   (void);
 
-#undef g_file_test
 
 gboolean
-g_file_test (const gchar *filename,
-             GFileTest    test)
+g_file_test_utf8 (const gchar *filename,
+                  GFileTest    test)
 {
-  gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
-  gboolean retval;
-
-  if (utf8_filename == NULL)
-    return FALSE;
-
-  retval = g_file_test_utf8 (utf8_filename, test);
-
-  g_free (utf8_filename);
-
-  return retval;
+  return g_file_test (filename, test);
 }
 
-#undef g_file_get_contents
-
 gboolean
-g_file_get_contents (const gchar  *filename,
-                     gchar       **contents,
-                     gsize        *length,
-                     GError      **error)
-{
-  gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, error);
-  gboolean retval;
-
-  if (utf8_filename == NULL)
-    return FALSE;
-
-  retval = g_file_get_contents_utf8 (utf8_filename, contents, length, error);
-
-  g_free (utf8_filename);
-
-  return retval;
-}
-
-#undef g_mkstemp
-
-static gint
-wrap_libc_open (const gchar *filename,
-                int          flags,
-                int          mode)
+g_file_get_contents_utf8 (const gchar  *filename,
+                          gchar       **contents,
+                          gsize        *length,
+                          GError      **error)
 {
-  return open (filename, flags, mode);
+  return g_file_get_contents (filename, contents, length, error);
 }
 
 gint
-g_mkstemp (gchar *tmpl)
+g_mkstemp_utf8 (gchar *tmpl)
 {
-  /* This is the backward compatibility system codepage version,
-   * thus use normal open().
-   */
-  return get_tmp_file (tmpl, wrap_libc_open,
-                      O_RDWR | O_CREAT | O_EXCL, 0600);
+  return g_mkstemp (tmpl);
 }
 
-#undef g_file_open_tmp
-
 gint
-g_file_open_tmp (const gchar  *tmpl,
-                gchar       **name_used,
-                GError      **error)
+g_file_open_tmp_utf8 (const gchar  *tmpl,
+                      gchar       **name_used,
+                      GError      **error)
 {
-  gchar *utf8_tmpl = g_locale_to_utf8 (tmpl, -1, NULL, NULL, error);
-  gchar *utf8_name_used;
-  gint retval;
-
-  if (utf8_tmpl == NULL)
-    return -1;
-
-  retval = g_file_open_tmp_utf8 (utf8_tmpl, &utf8_name_used, error);
-  
-  if (retval == -1)
-    return -1;
-
-  if (name_used)
-    *name_used = g_locale_from_utf8 (utf8_name_used, -1, NULL, NULL, NULL);
-
-  g_free (utf8_name_used);
-
-  return retval;
+  return g_file_open_tmp (tmpl, name_used, error);
 }
 
-#undef g_get_current_dir
-
 gchar *
-g_get_current_dir (void)
+g_get_current_dir_utf8 (void)
 {
-  gchar *utf8_dir = g_get_current_dir_utf8 ();
-  gchar *dir = g_locale_from_utf8 (utf8_dir, -1, NULL, NULL, NULL);
-  g_free (utf8_dir);
-  return dir;
+  return g_get_current_dir ();
 }
 
 #endif
-
diff --git a/glib/gfileutils.h b/glib/gfileutils.h
index fce5c50..f5f0827 100644
--- a/glib/gfileutils.h
+++ b/glib/gfileutils.h
@@ -176,33 +176,6 @@ gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC;
 GLIB_AVAILABLE_IN_ALL
 gchar *g_path_get_dirname  (const gchar *file_name) G_GNUC_MALLOC;
 
-#ifndef __GTK_DOC_IGNORE__
-#ifdef G_OS_WIN32
-#define g_file_test         g_file_test_utf8
-#define g_file_get_contents g_file_get_contents_utf8
-#define g_mkstemp           g_mkstemp_utf8
-#define g_file_open_tmp     g_file_open_tmp_utf8
-#define g_get_current_dir   g_get_current_dir_utf8
-
-GLIB_AVAILABLE_IN_ALL
-gboolean g_file_test_utf8         (const gchar  *filename,
-                                   GFileTest     test);
-GLIB_AVAILABLE_IN_ALL
-gboolean g_file_get_contents_utf8 (const gchar  *filename,
-                                   gchar       **contents,
-                                   gsize        *length,
-                                   GError      **error);
-GLIB_AVAILABLE_IN_ALL
-gint     g_mkstemp_utf8           (gchar        *tmpl);
-GLIB_AVAILABLE_IN_ALL
-gint     g_file_open_tmp_utf8     (const gchar  *tmpl,
-                                   gchar       **name_used,
-                                   GError      **error);
-GLIB_AVAILABLE_IN_ALL
-gchar   *g_get_current_dir_utf8   (void);
-#endif /* G_OS_WIN32 */
-#endif /* __GTK_DOC_IGNORE__ */
-
 G_END_DECLS
 
 #endif /* __G_FILEUTILS_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]