registrybinary: Fix compatibility with GLib 2.25 when using MSVC

Newer GLib uses a new type for g_stat() and friends to improve
Windows compatibility. On POSIX this is a typedef to struct stat.

Fixes bug #623875.
This commit is contained in:
David Hoyt 2010-07-08 21:04:54 +02:00 committed by Sebastian Dröge
parent 9d0e2e7252
commit c53457976e
3 changed files with 31 additions and 4 deletions

View file

@ -670,7 +670,11 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
GModule *module; GModule *module;
gboolean ret; gboolean ret;
gpointer ptr; gpointer ptr;
#if GLIB_CHECK_VERSION(2,25,0)
GStatBuf file_status;
#else
struct stat file_status; struct stat file_status;
#endif
GstRegistry *registry; GstRegistry *registry;
gboolean new_plugin = TRUE; gboolean new_plugin = TRUE;
@ -1466,7 +1470,13 @@ gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin,
} }
static guint static guint
gst_plugin_ext_dep_get_hash_from_stat_entry (struct stat *s) gst_plugin_ext_dep_get_hash_from_stat_entry (
#if GLIB_CHECK_VERSION(2,25,0)
GStatBuf * s
#else
struct stat *s
#endif
)
{ {
if (!(s->st_mode & (S_IFDIR | S_IFREG))) if (!(s->st_mode & (S_IFDIR | S_IFREG)))
return (guint) - 1; return (guint) - 1;
@ -1510,7 +1520,7 @@ gst_plugin_ext_dep_scan_dir_and_match_names (GstPlugin * plugin,
GDir *dir; GDir *dir;
guint hash = 0; guint hash = 0;
recurse_dirs = !!(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE); recurse_dirs = ! !(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE);
dir = g_dir_open (path, 0, &err); dir = g_dir_open (path, 0, &err);
if (dir == NULL) { if (dir == NULL) {
@ -1523,7 +1533,11 @@ gst_plugin_ext_dep_scan_dir_and_match_names (GstPlugin * plugin,
* the same order, and not in a random order */ * the same order, and not in a random order */
while ((entry = g_dir_read_name (dir))) { while ((entry = g_dir_read_name (dir))) {
gboolean have_match; gboolean have_match;
#if GLIB_CHECK_VERSION(2,25,0)
GStatBuf s;
#else
struct stat s; struct stat s;
#endif
gchar *full_path; gchar *full_path;
guint fhash; guint fhash;
@ -1572,15 +1586,20 @@ gst_plugin_ext_dep_scan_path_with_filenames (GstPlugin * plugin,
if (filenames == NULL || *filenames == NULL) if (filenames == NULL || *filenames == NULL)
filenames = empty_filenames; filenames = empty_filenames;
recurse_into_dirs = !!(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE); recurse_into_dirs = ! !(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE);
partial_names = !!(flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX); partial_names = ! !(flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX);
/* if we can construct the exact paths to check with the data we have, just /* if we can construct the exact paths to check with the data we have, just
* stat them one by one; this is more efficient than opening the directory * stat them one by one; this is more efficient than opening the directory
* and going through each entry to see if it matches one of our filenames. */ * and going through each entry to see if it matches one of our filenames. */
if (!recurse_into_dirs && !partial_names) { if (!recurse_into_dirs && !partial_names) {
for (i = 0; filenames[i] != NULL; ++i) { for (i = 0; filenames[i] != NULL; ++i) {
#if GLIB_CHECK_VERSION(2,25,0)
GStatBuf s;
#else
struct stat s; struct stat s;
#endif
gchar *full_path; gchar *full_path;
guint fhash; guint fhash;

View file

@ -1106,7 +1106,11 @@ gst_registry_scan_path_level (GstRegistryScanContext * context,
return FALSE; return FALSE;
while ((dirent = g_dir_read_name (dir))) { while ((dirent = g_dir_read_name (dir))) {
#if GLIB_CHECK_VERSION(2,25,0)
GStatBuf file_status;
#else
struct stat file_status; struct stat file_status;
#endif
filename = g_build_filename (path, dirent, NULL); filename = g_build_filename (path, dirent, NULL);
if (g_stat (filename, &file_status) < 0) { if (g_stat (filename, &file_status) < 0) {

View file

@ -363,7 +363,11 @@ gst_registry_binary_write_cache (GstRegistry * registry, const char *location)
continue; continue;
if (plugin->flags & GST_PLUGIN_FLAG_CACHED) { if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
#if GLIB_CHECK_VERSION(2,25,0)
GStatBuf statbuf;
#else
struct stat statbuf; struct stat statbuf;
#endif
if (g_stat (plugin->filename, &statbuf) < 0 || if (g_stat (plugin->filename, &statbuf) < 0 ||
plugin->file_mtime != statbuf.st_mtime || plugin->file_mtime != statbuf.st_mtime ||