]> git.street.me.uk Git - andy/viking.git/commitdiff
Portability: replace mkdir by g_mkdir
authorMathieu Albinet <mathieu17@gmail.com>
Sat, 12 Apr 2008 20:16:07 +0000 (20:16 +0000)
committerMathieu Albinet <mathieu17@gmail.com>
Sat, 12 Apr 2008 20:16:07 +0000 (20:16 +0000)
This allows to reduce conditionnal compilation complexity.

Based on work done by Mathieu Albinet for windows port

ChangeLog
configure.ac
src/download.c
src/osm-traces.c
src/thumbnails.c
src/vikmapslayer.c
src/vikwindow.c

index a16f727140a7b0f4a5330636fbe68a719a0a8eeb..063e0376b2ad6201bf3af4443ee3fa56216246dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 Guilhem Bonnefille <guilhem.bonnefille@gmail.com>:
 Mathieu Albinet <mathieu17@gmail.com>:
        * Portability: reduce unistd.h dependency
+       * Portability: replace mkdir by g_mkdir
 
 2008-03-27:
 Mathieu Albinet <mathieu17@gmail.com>:
index 380e51a79fd2ada31b8ecb9b522ff9b4b2772c38..5f5440b5486feb531b500dfd6bb138bbbd4c9e7c 100644 (file)
@@ -40,7 +40,7 @@ AC_TYPE_MODE_T
 # Checks for library functions.
 AC_FUNC_STAT
 AC_FUNC_STRTOD
-AC_CHECK_FUNCS([bzero floor gethostbyname memset mkdir mkdtemp pow realpath socket sqrt strcasecmp strchr strdup strncasecmp strtol strtoul])
+AC_CHECK_FUNCS([bzero floor gethostbyname memset mkdtemp pow realpath socket sqrt strcasecmp strchr strdup strncasecmp strtol strtoul])
 
 # Expat
 AM_WITH_EXPAT
index 827167f9d8ea984f178bc4812047126acd38fa9c..3063bfa55866830c1a0fb2169597d866f2feff10 100644 (file)
@@ -29,8 +29,8 @@
 #include <string.h>
 #include <strings.h>
 #include <gtk/gtk.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 #include <glib/gi18n.h>
 
 #include "download.h"
@@ -53,7 +53,6 @@ char *dirname ( char * dir )
 
 #else
 
-#include <sys/types.h>
 
 /* dirname */
 #include <libgen.h>
@@ -110,15 +109,9 @@ static int download( const char *hostname, const char *uri, const char *fn, Down
     if ( errno == ENOENT)
     {
       char *tmp = g_strdup ( fn );
-#ifdef WINDOWS
-      mkdir( dirname ( dirname ( tmp ) ) );
-      g_free ( tmp ); tmp = g_strdup ( fn );
-      mkdir( dirname ( tmp ) );
-#else
-      mkdir( dirname ( dirname ( tmp ) ), 0777 );
+      g_mkdir( dirname ( dirname ( tmp ) ), 0777 );
       g_free ( tmp ); tmp = g_strdup ( fn );
-      mkdir( dirname ( tmp ), 0777 );
-#endif
+      g_mkdir( dirname ( tmp ), 0777 );
       g_free ( tmp );
     }
     /* create placeholder file */
index c56a379a2cc518152008b31825c0c2b23fa82171..d1ea9c65911853e0122f856d72f7ef9e01bbf457 100644 (file)
@@ -24,8 +24,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <errno.h>
 
 #include <curl/curl.h>
index 6d42bd5f8b4f0ee5b7f0001045f0d3787d27dba3..3bc39ce0e9e2f380114fd63b7f6690983755edd9 100644 (file)
 #endif
 
 #include <stdlib.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <errno.h>
 #include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 #include "viking.h"
 #include "thumbnails.h"
 #include "thumbnails_pixbuf.h"
@@ -67,7 +65,6 @@
 #define HOME_DIR "C:\\VIKING"
 #define THUMB_DIR "\\THUMBNAILS\\" /* viking maps default viking\maps */
 #define THUMB_SUB_DIR "normal\\"
-#define mkdir(a,b) mkdir(a)
 #define realpath(X,Y) _fullpath(Y,X,MAX_PATH)
 
 #else
@@ -191,12 +188,12 @@ static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full)
                
        to = g_string_new(HOME_DIR);
 #ifndef WINDOWS
-       mkdir(to->str, 0700);
+       g_mkdir(to->str, 0700);
 #endif
        g_string_append(to, THUMB_DIR);
-       mkdir(to->str, 0700);
+       g_mkdir(to->str, 0700);
        g_string_append(to, THUMB_SUB_DIR);
-       mkdir(to->str, 0700);
+       g_mkdir(to->str, 0700);
        g_string_append(to, md5);
        name_len = to->len + 4; /* Truncate to this length when renaming */
 #ifdef WINDOWS
index 3deb773e1f631425ffb0d50be9457434f8afb25c..a1c2f96795d3dad81d890389fbb49e087ee567de 100644 (file)
@@ -51,8 +51,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <sys/stat.h>
-#include <sys/types.h>
 
 #include "mapcache.h"
 /* only for dialog.h -- ugh */
@@ -300,11 +298,7 @@ static void maps_layer_mkdir_if_default_dir ( VikMapsLayer *vml )
 {
   if ( vml->cache_dir && strcmp ( vml->cache_dir, MAPS_CACHE_DIR ) == 0 && g_file_test ( vml->cache_dir, G_FILE_TEST_EXISTS ) == FALSE )
   {
-#ifdef WINDOWS
-    mkdir ( vml->cache_dir );
-#else
-    mkdir ( vml->cache_dir, 0777 );
-#endif
+    g_mkdir ( vml->cache_dir, 0777 );
   }
 }
 
index 599afb31dbb2ee57a8302298bcc472fbb29997cd..75c9577b70d9b7f2e257d718a1080b4c3868e434 100644 (file)
 #include <math.h>
 #include <string.h>
 #include <ctype.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 #include <glib/gprintf.h>
 #include <glib/gi18n.h>
-#ifdef WINDOWS
-/* TODO IMPORTANT: mkdir for windows header? is it called 'mkdir' */
-#define make_dir(dir) mkdir(dir)
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#define make_dir(dir) mkdir(dir,0777)
-#endif
 
 #define VIKING_WINDOW_WIDTH      1000
 #define VIKING_WINDOW_HEIGHT     800
@@ -1567,7 +1561,7 @@ static void save_image_dir ( VikWindow *vw, const gchar *fn, guint w, guint h, g
 
   g_assert ( vik_viewport_get_coord_mode ( vw->viking_vvp ) == VIK_COORD_UTM );
 
-  make_dir(fn);
+  g_mkdir(fn,0777);
 
   utm_orig = *((const struct UTM *)vik_viewport_get_center ( vw->viking_vvp ));