mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
xdgmime - support cache files with minor version 2
This commit is contained in:
parent
ce239a010e
commit
7c27df1fee
@ -73,11 +73,13 @@
|
||||
#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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user