[easytag/wip/win32] Use g_mkstemp() instead of mkstemp()



commit 2529ec2830635c9f5da286f990ae4e32ad32a9bc
Author: David King <amigadave amigadave com>
Date:   Mon Jan 25 18:54:25 2016 +0000

    Use g_mkstemp() instead of mkstemp()
    
    As filenames are always in the GLib filename encoding, make sure to use
    the appropriate GLib function.

 configure.ac         |    2 +-
 src/browser.c        |    2 +-
 src/misc.c           |    2 +-
 src/win32/win32dep.c |   17 -----------------
 src/win32/win32dep.h |    5 -----
 5 files changed, 3 insertions(+), 25 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e2b4542..5f79f1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -360,7 +360,7 @@ AX_COMPILER_FLAGS([WARN_CFLAGS], [WARN_LDFLAGS],
 dnl -------------------------------
 dnl Checks for library functions.
 dnl -------------------------------
-AC_CHECK_FUNCS([mkstemp truncate])
+AC_CHECK_FUNCS([truncate])
 
 GLIB_GSETTINGS
 
diff --git a/src/browser.c b/src/browser.c
index eb6432b..1fb4de6 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -4341,7 +4341,7 @@ Rename_Directory (EtBrowser *self)
     tmp_path = g_strdup_printf("%s.XXXXXX",last_path);
     tmp_path_utf8 = g_filename_display_name (tmp_path);
 
-    if ( (fd_tmp = mkstemp(tmp_path)) >= 0 )
+    if ((fd_tmp = g_mkstemp (tmp_path)) >= 0)
     {
         /* TODO: handle error. */
         g_close (fd_tmp, NULL);
diff --git a/src/misc.c b/src/misc.c
index e5b069e..326ffe6 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -431,7 +431,7 @@ et_rename_file (const char *old_filepath,
             tmp_filename = g_strconcat (old_filepath, ".XXXXXX", NULL);
 
             old_mode = umask (077);
-            fd = mkstemp (tmp_filename);
+            fd = g_mkstemp (tmp_filename);
             umask (old_mode);
 
             if (fd >= 0)
diff --git a/src/win32/win32dep.c b/src/win32/win32dep.c
index e7f7f9c..3e96dd7 100644
--- a/src/win32/win32dep.c
+++ b/src/win32/win32dep.c
@@ -109,23 +109,6 @@ weasytag_locale_dir (void)
 }
 
 /* Miscellaneous */
-#ifndef HAVE_MKSTEMP
-/* emulate the unix function */
-gint
-et_w32_mkstemp (gchar *template)
-{
-    int fd = -1;
-
-    char *str = mktemp(template);
-    if(str != NULL)
-    {
-        fd  = g_open (str, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
-    }
-
-    return fd;
-}
-#endif /* !HAVE_MKSTEMP */
-
 #ifndef HAVE_TRUNCATE
 gint
 et_w32_truncate (const gchar *path, off_t length)
diff --git a/src/win32/win32dep.h b/src/win32/win32dep.h
index abb180c..a2cd069 100644
--- a/src/win32/win32dep.h
+++ b/src/win32/win32dep.h
@@ -48,11 +48,6 @@ G_BEGIN_DECLS
 /* Determine EasyTAG paths */
 const gchar * weasytag_locale_dir (void);
 
-#ifndef HAVE_MKSTEMP
-#define et_w32_mkstemp mkstemp
-extern gint et_w32_mkstemp (char *template);
-#endif /* !HAVE_MKSTEMP */
-
 #ifndef HAVE_TRUNCATE
 #define et_w32_truncate truncate
 extern gint et_w32_truncate (const gchar *path, off_t length);


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