New minimum requirement of GTK+2/GLIB for Xarchiver
Jean-François Wauthy
pollux at xfce.org
Thu Aug 3 14:31:31 CEST 2006
Le jeudi 03 août 2006 à 13:59 +0200, Jean-François Wauthy a écrit :
Use #if, #else and #endif as following otherwise building xarchiver will
fail with Glib < 2.8.0 because the header won't contain
g_mkdir_with_parents; stupid me
> there you go:
>
> #include <errno.h>
>
> int
> xarchiver_mkdir_with_parents (const gchar * pathname, int mode)
> {
#if GTK_CHECK_VERSION(2, 8, 0)
> return g_mkdir_with_parents (pathname, mode);
#else
> gchar *fn, *p;
>
> if (pathname == NULL || *pathname == '\0') {
> errno = EINVAL;
> return -1;
> }
>
> fn = g_strdup (pathname);
>
> if (g_path_is_absolute (fn))
> p = (gchar *) g_path_skip_root (fn);
> else
> p = fn;
>
> do {
> while (*p && !G_IS_DIR_SEPARATOR (*p))
> p++;
>
> if (!*p)
> p = NULL;
> else
> *p = '\0';
>
> if (!g_file_test (fn, G_FILE_TEST_EXISTS)) {
> if (g_mkdir (fn, mode) == -1) {
> int errno_save = errno;
> g_free (fn);
> errno = errno_save;
> return -1;
> }
> }
> else if (!g_file_test (fn, G_FILE_TEST_IS_DIR)) {
> g_free (fn);
> errno = ENOTDIR;
> return -1;
> }
> if (p) {
> *p++ = G_DIR_SEPARATOR;
> while (*p && G_IS_DIR_SEPARATOR (*p))
> p++;
> }
> }
> while (p);
>
> g_free (fn);
>
> return 0;
#endif
> }
--
Jean-François Wauthy <pollux at xfce.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 192 bytes
Desc: Ceci est une partie de message num?riquement sign?e
URL: <http://mail.xfce.org/pipermail/xfce4-dev/attachments/20060803/63583e01/attachment.pgp>
More information about the Xfce4-dev
mailing list