[Commits] [SCM] claws branch, master, updated. 3.11.1-156-g514d0e3

ticho at claws-mail.org ticho at claws-mail.org
Mon Jun 22 21:16:26 CEST 2015


The branch, master has been updated
       via  514d0e31724a6943dfb22351b2c92cbd88da5391 (commit)
      from  568eed69504b569c89ac8a55d673d2ee212b3da4 (commit)

Summary of changes:
 src/common/utils.c                |   42 ++-----------------------------------
 src/plugins/mailmbox/mailmbox.c   |    2 +-
 src/plugins/mailmbox/mmapstring.c |    3 ++-
 3 files changed, 5 insertions(+), 42 deletions(-)


- Log -----------------------------------------------------------------
commit 514d0e31724a6943dfb22351b2c92cbd88da5391
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Jun 22 21:14:39 2015 +0200

    Use g_mkstemp() instead of mkstemp().
    
    Also, removed our implementation of mkstemp() for Windows. Glib
    has us covered.

diff --git a/src/common/utils.c b/src/common/utils.c
index 17e839d..51bc5e1 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -218,37 +218,6 @@ int g_open(const gchar *filename, int flags, int mode)
 #endif /* G_OS_UNIX */
 
 
-#ifdef G_OS_WIN32
-gint mkstemp_name(gchar *template, gchar **name_used)
-{
-	static gulong count=0; /* W32-_mktemp only supports up to 27
-				  tempfiles... */
-	int tmpfd;
-
-	*name_used = g_strdup_printf("%s.%ld",_mktemp(template),count++);
-	tmpfd = g_open (*name_used, (O_CREAT | O_RDWR | O_BINARY),
-				    (S_IRUSR | S_IWUSR));
-
-	tempfiles=g_slist_append(tempfiles, g_strdup(*name_used));
-	if (tmpfd<0) {
-		perror(g_strdup_printf("cant create %s",*name_used));
-		return -1;
-	}
-	else
-		return tmpfd;
-}
-#endif /* G_OS_WIN32 */
-
-#ifdef G_OS_WIN32
-gint mkstemp(gchar *template)
-{
-	gchar *dummyname;
-	gint res = mkstemp_name(template, &dummyname);
-	g_free(dummyname);
-	return res;
-}
-#endif /* G_OS_WIN32 */
-
 GSList *slist_copy_deep(GSList *list, GCopyFunc func)
 {
 #if GLIB_CHECK_VERSION(2, 34, 0)
@@ -3093,7 +3062,7 @@ FILE *my_tmpfile(void)
 	memcpy(fname + tmplen + 1, progname, proglen);
 	memcpy(fname + tmplen + 1 + proglen, suffix, sizeof(suffix));
 
-	fd = mkstemp(fname);
+	fd = g_mkstemp(fname);
 	if (fd < 0)
 		return tmpfile();
 
@@ -3124,17 +3093,10 @@ FILE *my_tmpfile(void)
 FILE *get_tmpfile_in_dir(const gchar *dir, gchar **filename)
 {
 	int fd;
-#ifdef G_OS_WIN32
-	char *template = g_strdup_printf ("%s%cclaws.XXXXXX",
-					  dir, G_DIR_SEPARATOR);
-	fd = mkstemp_name(template, filename);
-	g_free(template);
-#else
 	*filename = g_strdup_printf("%s%cclaws.XXXXXX", dir, G_DIR_SEPARATOR);
-	fd = mkstemp(*filename);
+	fd = g_mkstemp(*filename);
 	if (fd < 0)
 		return NULL;
-#endif
 	return fdopen(fd, "w+");
 }
 
diff --git a/src/plugins/mailmbox/mailmbox.c b/src/plugins/mailmbox/mailmbox.c
index 3c4ada5..1d0578d 100644
--- a/src/plugins/mailmbox/mailmbox.c
+++ b/src/plugins/mailmbox/mailmbox.c
@@ -1258,7 +1258,7 @@ int claws_mailmbox_expunge_no_lock(struct claws_mailmbox_folder * folder)
   }
 
   snprintf(tmpfile, PATH_MAX, "%sXXXXXX", folder->mb_filename);
-  dest_fd = mkstemp(tmpfile);
+  dest_fd = g_mkstemp(tmpfile);
 
   if (dest_fd < 0) {
     res = MAILMBOX_ERROR_FILE;
diff --git a/src/plugins/mailmbox/mmapstring.c b/src/plugins/mailmbox/mmapstring.c
index a7baa17..2bf3582 100644
--- a/src/plugins/mailmbox/mmapstring.c
+++ b/src/plugins/mailmbox/mmapstring.c
@@ -37,6 +37,7 @@
 
 #include "chash.h"
 
+#include <glib.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/mman.h>
@@ -188,7 +189,7 @@ static MMAPString * mmap_string_realloc_file(MMAPString * string)
     strcat(tmpfilename, tmpdir);
     strcat(tmpfilename, "/libetpan-mmapstring-XXXXXX");
 
-    fd = mkstemp(tmpfilename);
+    fd = g_mkstemp(tmpfilename);
     if (fd == -1)
       return NULL;
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list