#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))
#ifdef WINDOWS
#define THUMB_DIR "\\THUMBNAILS\\" /* viking maps default viking\maps */
#define THUMB_SUB_DIR "normal\\"
-#define realpath(X,Y) _fullpath(Y,X,MAX_PATH)
-
#else
#define THUMB_DIR "/.thumbnails/"
#define THUMB_SUB_DIR "normal/"
#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);
static GdkPixbuf *child_create_thumbnail(const gchar *path);
if (w <= max_w && h <= max_h)
{
- gdk_pixbuf_ref(src);
+ g_object_ref ( G_OBJECT ( src ) );
return src;
}
else
GdkPixbuf *image, *tmpbuf;
image = gdk_pixbuf_new_from_file(path, NULL);
+ if (!image)
+ return NULL;
+
tmpbuf = gdk_pixbuf_apply_embedded_orientation(image);
g_object_unref(G_OBJECT(image));
image = tmpbuf;
if (image)
{
GdkPixbuf *thumb = save_thumbnail(path, image);
- gdk_pixbuf_unref ( image );
+ g_object_unref ( G_OBJECT ( image ) );
return thumb;
}
ssize = g_strdup_printf(ST_SIZE_FMT, info.st_size);
smtime = g_strdup_printf("%ld", (long) info.st_mtime);
- path = pathdup(pathname);
+ path = file_realpath_dup(pathname);
uri = g_strconcat("file://", path, NULL);
md5 = md5_hash(uri);
g_free(path);
const char *ssize, *smtime;
struct stat info;
- path = pathdup(pathname);
+ path = file_realpath_dup(pathname);
uri = g_strconcat("file://", path, NULL);
md5 = md5_hash(uri);
g_free(uri);
goto out;
err:
if (thumb)
- gdk_pixbuf_unref(thumb);
+ g_object_unref ( G_OBJECT ( thumb ) );
thumb = NULL;
out:
g_free(path);
return thumb;
}
-/* pathdup() stuff */
-
-static char *pathdup(const char *path)
-{
- char real[MAXPATHLEN];
-
- g_return_val_if_fail(path != NULL, NULL);
-
- if (realpath(path, real))
- return g_strdup(real);
-
- return g_strdup(path);
-}
-
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. The original code was