xdgmime - support cache files with minor version 2
authorAlexander Larsson <alexl@redhat.com>
Fri, 2 Oct 2009 07:48:35 +0000 (09:48 +0200)
committerAlexander Larsson <alexl@redhat.com>
Fri, 2 Oct 2009 10:55:54 +0000 (12:55 +0200)
gio/xdgmime/xdgmimecache.c

index 5bdac5b..0f2d83a 100644 (file)
 #endif
 
 #define MAJOR_VERSION 1
-#define MINOR_VERSION 1
+#define MINOR_VERSION_MIN 1
+#define MINOR_VERSION_MAX 2
 
 struct _XdgMimeCache
 {
   int ref_count;
+  int minor;
 
   size_t  size;
   char   *buffer;
@@ -116,6 +118,7 @@ _xdg_mime_cache_new_from_file (const char *file_name)
   int fd = -1;
   struct stat st;
   char *buffer = NULL;
+  int minor;
 
   /* Open the file and map it into memory */
   fd = open (file_name, O_RDONLY|_O_BINARY, 0);
@@ -131,9 +134,11 @@ _xdg_mime_cache_new_from_file (const char *file_name)
   if (buffer == MAP_FAILED)
     goto done;
 
+  minor = GET_UINT16 (buffer, 2);
   /* Verify version */
   if (GET_UINT16 (buffer, 0) != MAJOR_VERSION ||
-      GET_UINT16 (buffer, 2) != MINOR_VERSION)
+      (minor < MINOR_VERSION_MIN ||
+       minor > MINOR_VERSION_MAX))
     {
       munmap (buffer, st.st_size);
 
@@ -141,6 +146,7 @@ _xdg_mime_cache_new_from_file (const char *file_name)
     }
   
   cache = (XdgMimeCache *) malloc (sizeof (XdgMimeCache));
+  cache->minor = minor;
   cache->ref_count = 1;
   cache->buffer = buffer;
   cache->size = st.st_size;