Files
gtk/demos/pixbuf-init.c
Eduard Braun 303858fa76 Consistently use g_stat and GStatBuf
Replace "stat struct" with "GStatBuf" and "stat" with "g_stat" where
appropriate to fix cross-platform issues, specifically on Windows.

Code should be identical on *nix but fixes some serious issues
on Windows:
- Field widths of "struct stat" are not constant on Windows.
  If the stat function does not match the stat struct used
  it will cause overwrites and undefined behavior
- The Windows stat function needs a properly encoded filename.
  In many places we pass an UTF-8 encoded value which breaks as soon
  as non-ASCII characters are involved.

https://bugzilla.gnome.org/show_bug.cgi?id=787772
2018-08-19 14:53:15 +02:00

19 lines
355 B
C

#include "config.h"
#include <glib.h>
#include <glib/gstdio.h>
static gboolean
file_exists (const char *filename)
{
GStatBuf statbuf;
return g_stat (filename, &statbuf) == 0;
}
void
pixbuf_init (void)
{
if (file_exists ("../gdk-pixbuf/libpixbufloader-pnm.la"))
g_setenv ("GDK_PIXBUF_MODULE_FILE", "../gdk-pixbuf/gdk-pixbuf.loaders", TRUE);
}