]> git.street.me.uk Git - andy/viking.git/blobdiff - src/thumbnails.c
Portability: replace mkdir by g_mkdir
[andy/viking.git] / src / thumbnails.c
index f132e756857fa412410e477f03bdf24c271b35ac..3bc39ce0e9e2f380114fd63b7f6690983755edd9 100644 (file)
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
-#include <sys/stat.h>
+#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"
 #undef MIN /* quit yer whining, gcc */
 #undef MAX
 #include <sys/param.h> /* for realpath() */
+#ifndef MAX
+/* We need MAX macro and some system does not offer it */
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
 
 #ifdef WINDOWS
 #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 MAX(a,b) (((a)>(b))?(a):(b))
 #define realpath(X,Y) _fullpath(Y,X,MAX_PATH)
 
 #else
 
 #define PIXMAP_THUMB_SIZE  128
 
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
 static char *md5_hash(const char *message);
 static char *pathdup(const char *path);
 static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full);
@@ -174,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