summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-06-29 11:55:22 (GMT)
committerBenjamin Otte <otte@gnome.org>2009-06-29 16:25:02 (GMT)
commitceba40c27d5166a07a0925d2e158ca1809cc1ce3 (patch)
treec45f014e128fb0d717a2fd1b939b74af485c68bb
parent2620c23577a73fa454298014680f4de46a69e7bb (diff)
downloadglib-ceba40c27d5166a07a0925d2e158ca1809cc1ce3.tar.gz
glib-ceba40c27d5166a07a0925d2e158ca1809cc1ce3.tar.xz
add private header with attribute ids
attribute ids are generated when the attribute hash is initialized. This way we can guarantee that the ids match every time.
-rw-r--r--gio/Makefile.am1
-rw-r--r--gio/gfileinfo-priv.h99
-rw-r--r--gio/gfileinfo.c79
3 files changed, 178 insertions, 1 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 1376443..59d5264 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -202,6 +202,7 @@ libgio_2_0_la_SOURCES = \
gfileenumerator.c \
gfileicon.c \
gfileinfo.c \
+ gfileinfo-priv.h \
gfileinputstream.c \
gfilemonitor.c \
gfilenamecompleter.c \
diff --git a/gio/gfileinfo-priv.h b/gio/gfileinfo-priv.h
new file mode 100644
index 0000000..f747ece
--- /dev/null
+++ b/gio/gfileinfo-priv.h
@@ -0,0 +1,99 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ * 2009 Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __G_FILE_INFO_PRIV_H__
+#define __G_FILE_INFO_PRIV_H__
+
+#include "gfileinfo.h"
+
+#define G_FILE_ATTRIBUTE_ID_STANDARD_TYPE (1048576 + 1)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_HIDDEN (1048576 + 2)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_BACKUP (1048576 + 3)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_SYMLINK (1048576 + 4)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_VIRTUAL (1048576 + 5)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_NAME (1048576 + 6)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_DISPLAY_NAME (1048576 + 7)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_EDIT_NAME (1048576 + 8)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_COPY_NAME (1048576 + 9)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_DESCRIPTION (1048576 + 10)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_ICON (1048576 + 11)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_CONTENT_TYPE (1048576 + 12)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_FAST_CONTENT_TYPE (1048576 + 13)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_SIZE (1048576 + 14)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_ALLOCATED_SIZE (1048576 + 15)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_SYMLINK_TARGET (1048576 + 16)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_TARGET_URI (1048576 + 17)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_SORT_ORDER (1048576 + 18)
+#define G_FILE_ATTRIBUTE_ID_ETAG_VALUE (2097152 + 1)
+#define G_FILE_ATTRIBUTE_ID_ID_FILE (3145728 + 1)
+#define G_FILE_ATTRIBUTE_ID_ID_FILESYSTEM (3145728 + 2)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_READ (4194304 + 1)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_WRITE (4194304 + 2)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_EXECUTE (4194304 + 3)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_DELETE (4194304 + 4)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_TRASH (4194304 + 5)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_RENAME (4194304 + 6)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_MOUNT (5242880 + 1)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_UNMOUNT (5242880 + 2)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_EJECT (5242880 + 3)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_UNIX_DEVICE (5242880 + 4)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_HAL_UDI (5242880 + 5)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_START (5242880 + 6)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_STOP (5242880 + 7)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_START_STOP_TYPE (5242880 + 8)
+#define G_FILE_ATTRIBUTE_ID_TIME_MODIFIED (6291456 + 1)
+#define G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC (6291456 + 2)
+#define G_FILE_ATTRIBUTE_ID_TIME_ACCESS (6291456 + 3)
+#define G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC (6291456 + 4)
+#define G_FILE_ATTRIBUTE_ID_TIME_CHANGED (6291456 + 5)
+#define G_FILE_ATTRIBUTE_ID_TIME_CHANGED_USEC (6291456 + 6)
+#define G_FILE_ATTRIBUTE_ID_TIME_CREATED (6291456 + 7)
+#define G_FILE_ATTRIBUTE_ID_TIME_CREATED_USEC (6291456 + 8)
+#define G_FILE_ATTRIBUTE_ID_UNIX_DEVICE (7340032 + 1)
+#define G_FILE_ATTRIBUTE_ID_UNIX_INODE (7340032 + 2)
+#define G_FILE_ATTRIBUTE_ID_UNIX_MODE (7340032 + 3)
+#define G_FILE_ATTRIBUTE_ID_UNIX_NLINK (7340032 + 4)
+#define G_FILE_ATTRIBUTE_ID_UNIX_UID (7340032 + 5)
+#define G_FILE_ATTRIBUTE_ID_UNIX_GID (7340032 + 6)
+#define G_FILE_ATTRIBUTE_ID_UNIX_RDEV (7340032 + 7)
+#define G_FILE_ATTRIBUTE_ID_UNIX_BLOCK_SIZE (7340032 + 8)
+#define G_FILE_ATTRIBUTE_ID_UNIX_BLOCKS (7340032 + 9)
+#define G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT (7340032 + 10)
+#define G_FILE_ATTRIBUTE_ID_DOS_IS_ARCHIVE (8388608 + 1)
+#define G_FILE_ATTRIBUTE_ID_DOS_IS_SYSTEM (8388608 + 2)
+#define G_FILE_ATTRIBUTE_ID_OWNER_USER (9437184 + 1)
+#define G_FILE_ATTRIBUTE_ID_OWNER_USER_REAL (9437184 + 2)
+#define G_FILE_ATTRIBUTE_ID_OWNER_GROUP (9437184 + 3)
+#define G_FILE_ATTRIBUTE_ID_THUMBNAIL_PATH (10485760 + 1)
+#define G_FILE_ATTRIBUTE_ID_THUMBNAILING_FAILED (10485760 + 2)
+#define G_FILE_ATTRIBUTE_ID_PREVIEW_ICON (11534336 + 1)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_SIZE (12582912 + 1)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_FREE (12582912 + 2)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_TYPE (12582912 + 3)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_READONLY (12582912 + 4)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_USE_PREVIEW (12582912 + 5)
+#define G_FILE_ATTRIBUTE_ID_GVFS_BACKEND (13631488 + 1)
+#define G_FILE_ATTRIBUTE_ID_SELINUX_CONTEXT (14680064 + 1)
+#define G_FILE_ATTRIBUTE_ID_TRASH_ITEM_COUNT (15728640 + 1)
+
+#endif /* __G_FILE_INFO_PRIV_H__ */
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index 2382b02..c5b8ca8 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -57,6 +57,7 @@
#include <string.h>
#include "gfileinfo.h"
+#include "gfileinfo-priv.h"
#include "gfileattribute-priv.h"
#include "gicon.h"
#include "glibintl.h"
@@ -182,7 +183,83 @@ ensure_attribute_hash (void)
ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
+#define REGISTER_ATTRIBUTE(name) G_STMT_START{\
+ guint _u = _lookup_attribute (G_FILE_ATTRIBUTE_ ## name); \
+ /* use for generating the ID: g_print ("#define G_FILE_ATTRIBUTE_ID_%s (%u + %u)\n", #name + 17, _u & ~ID_MASK, _u & ID_MASK); */ \
+ g_assert (_u == G_FILE_ATTRIBUTE_ID_ ## name); \
+}G_STMT_END
+
+ REGISTER_ATTRIBUTE (STANDARD_TYPE);
+ REGISTER_ATTRIBUTE (STANDARD_IS_HIDDEN);
+ REGISTER_ATTRIBUTE (STANDARD_IS_BACKUP);
+ REGISTER_ATTRIBUTE (STANDARD_IS_SYMLINK);
+ REGISTER_ATTRIBUTE (STANDARD_IS_VIRTUAL);
+ REGISTER_ATTRIBUTE (STANDARD_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_DISPLAY_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_EDIT_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_COPY_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_DESCRIPTION);
+ REGISTER_ATTRIBUTE (STANDARD_ICON);
+ REGISTER_ATTRIBUTE (STANDARD_CONTENT_TYPE);
+ REGISTER_ATTRIBUTE (STANDARD_FAST_CONTENT_TYPE);
+ REGISTER_ATTRIBUTE (STANDARD_SIZE);
+ REGISTER_ATTRIBUTE (STANDARD_ALLOCATED_SIZE);
+ REGISTER_ATTRIBUTE (STANDARD_SYMLINK_TARGET);
+ REGISTER_ATTRIBUTE (STANDARD_TARGET_URI);
+ REGISTER_ATTRIBUTE (STANDARD_SORT_ORDER);
+ REGISTER_ATTRIBUTE (ETAG_VALUE);
+ REGISTER_ATTRIBUTE (ID_FILE);
+ REGISTER_ATTRIBUTE (ID_FILESYSTEM);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_READ);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_WRITE);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_EXECUTE);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_DELETE);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_TRASH);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_RENAME);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_MOUNT);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_UNMOUNT);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_EJECT);
+ REGISTER_ATTRIBUTE (MOUNTABLE_UNIX_DEVICE);
+ REGISTER_ATTRIBUTE (MOUNTABLE_HAL_UDI);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_START);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_STOP);
+ REGISTER_ATTRIBUTE (MOUNTABLE_START_STOP_TYPE);
+ REGISTER_ATTRIBUTE (TIME_MODIFIED);
+ REGISTER_ATTRIBUTE (TIME_MODIFIED_USEC);
+ REGISTER_ATTRIBUTE (TIME_ACCESS);
+ REGISTER_ATTRIBUTE (TIME_ACCESS_USEC);
+ REGISTER_ATTRIBUTE (TIME_CHANGED);
+ REGISTER_ATTRIBUTE (TIME_CHANGED_USEC);
+ REGISTER_ATTRIBUTE (TIME_CREATED);
+ REGISTER_ATTRIBUTE (TIME_CREATED_USEC);
+ REGISTER_ATTRIBUTE (UNIX_DEVICE);
+ REGISTER_ATTRIBUTE (UNIX_INODE);
+ REGISTER_ATTRIBUTE (UNIX_MODE);
+ REGISTER_ATTRIBUTE (UNIX_NLINK);
+ REGISTER_ATTRIBUTE (UNIX_UID);
+ REGISTER_ATTRIBUTE (UNIX_GID);
+ REGISTER_ATTRIBUTE (UNIX_RDEV);
+ REGISTER_ATTRIBUTE (UNIX_BLOCK_SIZE);
+ REGISTER_ATTRIBUTE (UNIX_BLOCKS);
+ REGISTER_ATTRIBUTE (UNIX_IS_MOUNTPOINT);
+ REGISTER_ATTRIBUTE (DOS_IS_ARCHIVE);
+ REGISTER_ATTRIBUTE (DOS_IS_SYSTEM);
+ REGISTER_ATTRIBUTE (OWNER_USER);
+ REGISTER_ATTRIBUTE (OWNER_USER_REAL);
+ REGISTER_ATTRIBUTE (OWNER_GROUP);
+ REGISTER_ATTRIBUTE (THUMBNAIL_PATH);
+ REGISTER_ATTRIBUTE (THUMBNAILING_FAILED);
+ REGISTER_ATTRIBUTE (PREVIEW_ICON);
+ REGISTER_ATTRIBUTE (FILESYSTEM_SIZE);
+ REGISTER_ATTRIBUTE (FILESYSTEM_FREE);
+ REGISTER_ATTRIBUTE (FILESYSTEM_TYPE);
+ REGISTER_ATTRIBUTE (FILESYSTEM_READONLY);
+ REGISTER_ATTRIBUTE (FILESYSTEM_USE_PREVIEW);
+ REGISTER_ATTRIBUTE (GVFS_BACKEND);
+ REGISTER_ATTRIBUTE (SELINUX_CONTEXT);
+ REGISTER_ATTRIBUTE (TRASH_ITEM_COUNT);
+
+#undef REGISTER_ATTRIBUTE
}
static guint32