gchar * gtkhtml_editor_find_data_file (const gchar *basename) { const gchar * const *datadirs; gchar *filename; g_return_val_if_fail (basename != NULL, NULL); /* Support running directly from the source tree. */ filename = g_build_filename (".", basename, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) return filename; g_free (filename); /* Check our own installation prefix. */ filename = g_build_filename ( DATADIR, GTKHTML_RELEASE_STRING, basename, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) return filename; g_free (filename); /* Check the standard system data directories. */ datadirs = g_get_system_data_dirs (); while (*datadirs != NULL) { filename = g_build_filename ( *datadirs++, GTKHTML_RELEASE_STRING, basename, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) return filename; g_free (filename); } /* Print a helpful message and die. */ g_printerr (DATA_FILE_NOT_FOUND_MESSAGE, basename); filename = g_build_filename ( DATADIR, GTKHTML_RELEASE_STRING, basename, NULL); g_printerr ("\t%s\n", filename); g_free (filename); datadirs = g_get_system_data_dirs (); while (*datadirs != NULL) { filename = g_build_filename ( *datadirs++, GTKHTML_RELEASE_STRING, basename, NULL); g_printerr ("\t%s\n", filename); g_free (filename); } g_printerr (MORE_INFORMATION_MESSAGE); abort (); return NULL; /* never gets here */ }
static void get_apps ( DRunModePrivateData *pd ) { TICK_N ( "Get Desktop apps (start)" ); get_apps_history ( pd ); gchar *dir; // First read the user directory. dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL ); walk_dir ( pd, dir, dir ); g_free ( dir ); TICK_N ( "Get Desktop apps (user dir)" ); // Then read thee system data dirs. const gchar * const * sys = g_get_system_data_dirs (); for ( const gchar * const *iter = sys; *iter != NULL; ++iter ) { gboolean unique = TRUE; // Stupid duplicate detection, better then walking dir. for ( const gchar *const *iterd = sys; iterd != iter; ++iterd ) { if ( g_strcmp0 ( *iter, *iterd ) == 0 ) { unique = FALSE; } } // Check, we seem to be getting empty string... if ( unique && ( **iter ) != '\0' ) { dir = g_build_filename ( *iter, "applications", NULL ); walk_dir ( pd, dir, dir ); g_free ( dir ); } } TICK_N ( "Get Desktop apps (system dirs)" ); }
/** * g_content_types_get_registered: * * Gets a list of strings containing all the registered content types * known to the system. The list and its data should be freed using * <programlisting> * g_list_free_full (list, g_free); * </programlisting> * * Returns: (element-type utf8) (transfer full): #GList of the registered content types */ GList * g_content_types_get_registered (void) { const char * const* dirs; GHashTable *mimetypes; GHashTableIter iter; gpointer key; int i; GList *l; mimetypes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); enumerate_mimetypes_dir (g_get_user_data_dir (), mimetypes); dirs = g_get_system_data_dirs (); for (i = 0; dirs[i] != NULL; i++) enumerate_mimetypes_dir (dirs[i], mimetypes); l = NULL; g_hash_table_iter_init (&iter, mimetypes); while (g_hash_table_iter_next (&iter, &key, NULL)) { l = g_list_prepend (l, key); g_hash_table_iter_steal (&iter); } g_hash_table_destroy (mimetypes); return l; }
void mpid_find_and_read_device_file (MPIDDevice *device, const char *device_file) { const char * const *data_dirs; int i; data_dirs = g_get_system_data_dirs (); for (i = 0; data_dirs[i] != NULL; i++) { char *filename; char *path; filename = g_strdup_printf ("%s.mpi", device_file); path = g_build_filename (data_dirs[i], "media-player-info", filename, NULL); g_free (filename); if (g_file_test (path, G_FILE_TEST_EXISTS)) { device->source = MPID_SOURCE_SYSTEM; mpid_read_device_file (device, path); g_free (path); return; } g_free (path); } /* device info file is missing */ mpid_debug ("unable to find device info file %s\n", device_file); device->error = MPID_ERROR_DEVICE_INFO_MISSING; }
static void initialise_schema_sources (void) { static gsize initialised; /* need a separate variable because 'schema_sources' may legitimately * be null if we have zero valid schema sources */ if G_UNLIKELY (g_once_init_enter (&initialised)) { const gchar * const *dirs; const gchar *path; gint i; /* iterate in reverse: count up, then count down */ dirs = g_get_system_data_dirs (); for (i = 0; dirs[i]; i++); while (i--) { gchar *dirname; dirname = g_build_filename (dirs[i], "glib-2.0", "schemas", NULL); try_prepend_dir (dirname); g_free (dirname); } if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL) try_prepend_dir (path); g_once_init_leave (&initialised, TRUE); } }
/** * fs_utils_get_default_codec_preferences: * @element: Element for which to fetch default codec preferences * * These default codec preferences should work with the elements that are * available in the main GStreamer element repositories. * They should be suitable for standards based protocols like SIP or XMPP. * * Returns: (element-type FsCodec) (transfer full): * The default codec preferences for this plugin. * This #GList should be freed with fs_codec_list_destroy() */ GList * fs_utils_get_default_codec_preferences (GstElement *element) { const gchar * const * system_data_dirs = g_get_system_data_dirs (); GList *codec_prefs = NULL; guint i; const gchar *factory_name = factory_name_from_element (element); if (!factory_name) return NULL; codec_prefs = load_default_codec_preferences_from_path (factory_name, g_get_user_data_dir ()); if (codec_prefs) return codec_prefs; for (i = 0; system_data_dirs[i]; i++) { codec_prefs = load_default_codec_preferences_from_path (factory_name, system_data_dirs[i]); if (codec_prefs) return codec_prefs; } return NULL; }
/** * fs_utils_get_default_rtp_header_extension_preferences * @element: Element for which to fetch default RTP Header Extension preferences * @media_type: The #FsMediaType for which to get default RTP Header Extension * preferences * * These default rtp header extension preferences should work with the elements * that are available in the main GStreamer element repositories. * They should be suitable for standards based protocols like SIP or XMPP. * * Returns: (element-type FsCodec) (transfer full): The default rtp * header extension preferences for this plugin, this #GList should be * freed with fs_codec_list_destroy() */ GList * fs_utils_get_default_rtp_header_extension_preferences (GstElement *element, FsMediaType media_type) { const gchar * const * system_data_dirs = g_get_system_data_dirs (); GList *rtp_hdrext_prefs = NULL; guint i; const gchar *factory_name = factory_name_from_element (element); if (!factory_name) return NULL; rtp_hdrext_prefs = load_default_rtp_hdrext_preferences_from_path ( factory_name, g_get_user_data_dir (), media_type); if (rtp_hdrext_prefs) return rtp_hdrext_prefs; for (i = 0; system_data_dirs[i]; i++) { rtp_hdrext_prefs = load_default_rtp_hdrext_preferences_from_path ( factory_name, system_data_dirs[i], media_type); if (rtp_hdrext_prefs) return rtp_hdrext_prefs; } return NULL; }
/* Returns TRUE if the file is in XDG_DATA_DIRS. This is used for deciding if a desktop file is "trusted" based on the path */ gboolean nautilus_is_in_system_dir (GFile *file) { const char * const * data_dirs; char *path; int i; gboolean res; if (!g_file_is_native (file)) { return FALSE; } path = g_file_get_path (file); res = FALSE; data_dirs = g_get_system_data_dirs (); for (i = 0; path != NULL && data_dirs[i] != NULL; i++) { if (g_str_has_prefix (path, data_dirs[i])) { res = TRUE; break; } } return res; }
static void tree_magic_init (void) { static gboolean initialized = FALSE; const gchar *dir; const gchar * const * dirs; int i; if (!initialized) { initialized = TRUE; xdg_mime_register_reload_callback (xdg_mime_reload, NULL, NULL); need_reload = TRUE; } if (need_reload) { need_reload = FALSE; tree_magic_shutdown (); dir = g_get_user_data_dir (); read_tree_magic_from_directory (dir); dirs = g_get_system_data_dirs (); for (i = 0; dirs[i]; i++) read_tree_magic_from_directory (dirs[i]); } }
static char * load_comment_for_mime (const char *mimetype) { const char * const* dirs; char *basename; char *comment; int i; basename = g_strdup_printf ("%s.xml", mimetype); comment = load_comment_for_mime_helper (g_get_user_data_dir (), basename); if (comment) { g_free (basename); return comment; } dirs = g_get_system_data_dirs (); for (i = 0; dirs[i] != NULL; i++) { comment = load_comment_for_mime_helper (dirs[i], basename); if (comment) { g_free (basename); return comment; } } g_free (basename); return g_strdup_printf (_("%s type"), mimetype); }
static gboolean spice_usbutil_load_usbids(void) { gboolean success = FALSE; g_mutex_lock(&usbids_load_mutex); if (usbids_vendor_count) { success = usbids_vendor_count > 0; goto leave; } #ifdef WITH_USBIDS success = spice_usbutil_parse_usbids(USB_IDS); #else { const gchar * const *dirs = g_get_system_data_dirs(); gchar *path = NULL; int i; for (i = 0; dirs[i]; ++i) { path = g_build_filename(dirs[i], "hwdata", "usb.ids", NULL); success = spice_usbutil_parse_usbids(path); SPICE_DEBUG("loading %s success: %s", path, spice_yes_no(success)); g_free(path); if (success) goto leave; } } #endif leave: g_mutex_unlock(&usbids_load_mutex); return success; }
/* load all mime.cache files on the system, * including /usr/share/mime/mime.cache, * /usr/local/share/mime/mime.cache, * and $HOME/.local/share/mime/mime.cache. */ void mime_cache_load_all() { const char* const * dirs; int i; const char filename[] = "/mime/mime.cache"; char* path; dirs = g_get_system_data_dirs(); n_caches = g_strv_length( (char**)dirs ) + 1; caches = (MimeCache**)g_slice_alloc( n_caches * sizeof(MimeCache*) ); path = g_build_filename( g_get_user_data_dir(), filename, NULL ); caches[0] = mime_cache_new( path ); g_free( path ); if( caches[0]->magic_max_extent > mime_cache_max_extent ) mime_cache_max_extent = caches[0]->magic_max_extent; for( i = 1; i < n_caches; ++i ) { path = g_build_filename( dirs[i - 1], filename, NULL ); caches[ i ] = mime_cache_new( path ); g_free( path ); if( caches[i]->magic_max_extent > mime_cache_max_extent ) mime_cache_max_extent = caches[i]->magic_max_extent; } mime_magic_buf = g_malloc( mime_cache_max_extent ); return ; }
static void search_providers_discover_thread (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) { GList *providers = NULL; const gchar * const *system_data_dirs; int idx; system_data_dirs = g_get_system_data_dirs (); for (idx = 0; system_data_dirs[idx] != NULL; idx++) { providers = g_list_concat (search_providers_discover_one_directory (system_data_dirs[idx], cancellable), providers); if (g_task_return_error_if_cancelled (task)) { g_list_free_full (providers, g_object_unref); return; } } g_task_return_pointer (task, providers, NULL); }
static gchar * find_file_common(const char *name) { gchar *filename; #if GLIB_CHECK_VERSION(2,6,0) const gchar *userdir; const gchar * const *sysdirs; userdir = g_get_user_data_dir(); filename = g_build_filename(userdir, name, NULL); if (g_file_test(filename, G_FILE_TEST_EXISTS)) return filename; g_free(filename); sysdirs = g_get_system_data_dirs(); for (; *sysdirs; sysdirs++) { filename = g_build_filename(*sysdirs, name, NULL); if (g_file_test(filename, G_FILE_TEST_EXISTS)) return filename; g_free(filename); } #endif filename = g_build_filename(DATADIR, name, NULL); if (g_file_test(filename, G_FILE_TEST_EXISTS)) return filename; g_free(filename); return NULL; }
static void get_apps ( DRunModePrivateData *pd ) { const char * const * dr = g_get_system_data_dirs (); const char * const * iter = dr; while ( iter != NULL && *iter != NULL && **iter != '\0' ) { gboolean skip = FALSE; for ( size_t i = 0; !skip && dr[i] != ( *iter ); i++ ) { skip = ( g_strcmp0 ( *iter, dr[i] ) == 0 ); } if ( skip ) { iter++; continue; } gchar *bp = g_build_filename ( *iter, "applications", NULL ); get_apps_dir ( pd, bp ); g_free ( bp ); iter++; } const char *d = g_get_user_data_dir (); for ( size_t i = 0; dr[i] != NULL; i++ ) { if ( g_strcmp0 ( d, dr[i] ) == 0 ) { // Done this already, no need to repeat. return; } } if ( d ) { gchar *bp = g_build_filename ( d, "applications", NULL ); get_apps_dir ( pd, bp ); g_free ( bp ); } }
static gboolean ccm_config_schema_get_filename (CCMConfigSchema * self) { g_return_val_if_fail (self != NULL, FALSE); const gchar *const *paths = g_get_system_data_dirs (); gboolean found = FALSE; gint cpt; for (cpt = 0; paths[cpt] && !found; cpt++) { gchar *filename = ccm_config_schema_get_path ((gchar *) paths[cpt], self->priv->screen, self->priv->name); if (filename && g_file_test (filename, G_FILE_TEST_EXISTS)) { self->priv->filename = filename; found = TRUE; } else g_free (filename); } return found; }
static void mx_icon_theme_init (MxIconTheme *self) { gint i; gchar *path; const gchar *theme; const gchar *datadir; const gchar * const *datadirs; MxIconThemePrivate *priv = self->priv = ICON_THEME_PRIVATE (self); /* /usr/share/pixmaps, /usr/share/icons and $HOME/.icons are named in the * icon theme spec, but we'll interpret this to look in the system data * dirs, as most other (well, gtk) toolkits do. */ datadirs = g_get_system_data_dirs (); for (i = 0; datadirs[i]; i++) { datadir = datadirs[i]; path = g_build_filename (G_DIR_SEPARATOR_S, datadir, "pixmaps", NULL); priv->search_paths = g_list_prepend (priv->search_paths, path); path = g_build_filename (G_DIR_SEPARATOR_S, datadir, "icons", NULL); priv->search_paths = g_list_prepend (priv->search_paths, path); } datadir = g_get_user_data_dir (); path = g_build_filename (G_DIR_SEPARATOR_S, datadir, "pixmaps", NULL); priv->search_paths = g_list_prepend (priv->search_paths, path); path = g_build_filename (G_DIR_SEPARATOR_S, datadir, "icons", NULL); priv->search_paths = g_list_prepend (priv->search_paths, path); path = g_build_filename (g_get_home_dir (), ".icons", NULL); priv->search_paths = g_list_prepend (priv->search_paths, path); priv->icon_hash = g_hash_table_new_full ((GHashFunc)mx_icon_theme_hash, (GEqualFunc)mx_icon_theme_equal_func, g_object_unref, mx_icon_theme_icon_hash_free); priv->theme_path_hash = g_hash_table_new_full (g_direct_hash, g_str_equal, NULL, g_free); priv->hicolor_file = mx_icon_theme_load_theme (self, "hicolor"); if (!priv->hicolor_file) g_warning ("Error loading fallback icon theme"); theme = g_getenv ("MX_ICON_THEME"); if (theme) mx_icon_theme_set_theme_name (self, theme); else { MxSettings *settings = mx_settings_get_default (); g_signal_connect (settings, "notify::icon-theme", G_CALLBACK (mx_icon_theme_changed_cb), self); mx_icon_theme_changed_cb (settings, NULL, self); } }
static int resource_open_default(struct sr_resource *res, const char *name, void *cb_data) { int64_t filesize; #ifdef FIRMWARE_DIR const char *builtindir; #endif const char *subdir; const char *const *datadirs; FILE *file; (void)cb_data; switch (res->type) { case SR_RESOURCE_FIRMWARE: #ifdef FIRMWARE_DIR builtindir = FIRMWARE_DIR; #endif subdir = "sigrok-firmware"; break; default: sr_err("%s: unknown type %d.", __func__, res->type); return SR_ERR_ARG; } file = try_open_file(g_get_user_data_dir(), subdir, name); /* * Scan the hard-coded directory before the system directories to * avoid picking up possibly outdated files from a system install. */ #ifdef FIRMWARE_DIR if (!file) file = try_open_file(builtindir, "", name); #endif if (!file) { datadirs = g_get_system_data_dirs(); while (*datadirs && !file) file = try_open_file(*datadirs++, subdir, name); } if (!file) { sr_dbg("Failed to locate '%s'.", name); return SR_ERR; } filesize = sr_file_get_size(file); if (filesize < 0) { sr_err("Failed to obtain size of '%s': %s", name, g_strerror(errno)); fclose(file); return SR_ERR; } res->size = filesize; res->handle = file; return SR_OK; }
/* * Get human-readable description of the mime-type * If locale is NULL, current locale will be used. * The returned string should be freed when no longer used. */ char* mime_type_get_desc( const char* type, const char* locale ) { char* desc; const gchar* const * dir; char file_path[ 256 ]; int acc; /* //sfm 0.7.7+ FIXED * FIXME: According to specs on freedesktop.org, user_data_dir has * higher priority than system_data_dirs, but in most cases, there was * no file, or very few files in user_data_dir, so checking it first will * result in many unnecessary open() system calls, yealding bad performance. * Since the spec really sucks, we don't follow it here. */ /* FIXME: This path shouldn't be hard-coded. */ g_snprintf( file_path, 256, "%s/mime/%s.xml", g_get_user_data_dir(), type ); #if defined(HAVE_EUIDACCESS) acc = euidaccess( file_path, F_OK ); #elif defined(HAVE_EACCESS) acc = eaccess( file_path, F_OK ); #else acc = 0; #endif if ( acc != -1 ) { desc = _mime_type_get_desc( file_path, locale ); if ( desc ) return desc; } // look in system dirs dir = g_get_system_data_dirs(); for( ; *dir; ++dir ) { /* FIXME: This path shouldn't be hard-coded. */ g_snprintf( file_path, 256, "%s/mime/%s.xml", *dir, type ); #if defined(HAVE_EUIDACCESS) acc = euidaccess( file_path, F_OK ); #elif defined(HAVE_EACCESS) acc = eaccess( file_path, F_OK ); #else acc = 0; #endif if ( acc != -1 ) { desc = _mime_type_get_desc( file_path, locale ); if( G_LIKELY(desc) ) return desc; } } return NULL; }
static G_CONST_RETURN char * G_CONST_RETURN * gjs_get_search_path(void) { char **search_path; /* not thread safe */ if (!gjs_search_path) { G_CONST_RETURN gchar* G_CONST_RETURN * system_data_dirs; const char *envstr; GPtrArray *path; gsize i; path = g_ptr_array_new(); /* in order of priority */ /* $GJS_PATH */ envstr = g_getenv("GJS_PATH"); if (envstr) { char **dirs, **d; dirs = g_strsplit(envstr, G_SEARCHPATH_SEPARATOR_S, 0); for (d = dirs; *d != NULL; d++) g_ptr_array_add(path, *d); /* we assume the array and strings are allocated separately */ g_free(dirs); } /* $XDG_DATA_DIRS /gjs-1.0 */ system_data_dirs = g_get_system_data_dirs(); for (i = 0; system_data_dirs[i] != NULL; ++i) { char *s; s = g_build_filename(system_data_dirs[i], "gjs-1.0", NULL); g_ptr_array_add(path, s); } /* ${libdir}/gjs-1.0 */ g_ptr_array_add(path, g_strdup(GJS_NATIVE_DIR)); /* ${datadir}/share/gjs-1.0 */ g_ptr_array_add(path, g_strdup(GJS_JS_DIR)); g_ptr_array_add(path, NULL); search_path = (char**)g_ptr_array_free(path, FALSE); gjs_search_path = search_path; } else { search_path = gjs_search_path; } return (G_CONST_RETURN char * G_CONST_RETURN *)search_path; }
void init_X11() { server.dsp = XOpenDisplay(NULL); if (!server.dsp) DIE("tint: could not open display."); server_init_atoms(); server.screen = DefaultScreen(server.dsp); server.root_win = RootWindow(server.dsp, server.screen); server.desktop = server_get_current_desktop(); server_init_visual(); XSetErrorHandler((XErrorHandler)server_catch_error); #ifdef HAVE_SN // Initialize startup-notification server.sn_dsp = sn_display_new(server.dsp, error_trap_push, error_trap_pop); server.pids = g_tree_new(cmp_ptr); // Setup a handler for child termination struct sigaction act; memset(&act, 0, sizeof(struct sigaction)); act.sa_handler = sigchld_handler; if (sigaction(SIGCHLD, &act, 0)) { perror("sigaction"); } #endif // HAVE_SN imlib_context_set_display(server.dsp); imlib_context_set_visual(server.visual); imlib_context_set_colormap(server.colormap); /* Catch events */ XSelectInput(server.dsp, server.root_win, PropertyChangeMask | StructureNotifyMask); setlocale(LC_ALL, ""); // config file use '.' as decimal separator setlocale(LC_NUMERIC, "POSIX"); // load default icon gchar* path; const gchar* const* data_dirs; data_dirs = g_get_system_data_dirs(); int i; for (i = 0; data_dirs[i] != NULL; i++) { path = g_build_filename(data_dirs[i], "tinto", "default_icon.png", NULL); if (g_file_test(path, G_FILE_TEST_EXISTS)) default_icon = imlib_load_image(path); g_free(path); } // get monitor and desktop config get_monitors(); get_desktops(); }
lfError lfDatabase::Load () { gchar *dirs [10]; const gchar *const *tmp; int ndirs = 0; dirs [ndirs++] = HomeDataDir; #ifdef CONF_DATADIR dirs [ndirs++] = (char *)CONF_DATADIR; #else extern gchar *_lf_get_database_dir (); dirs [ndirs++] = _lf_get_database_dir (); #endif int static_ndirs = ndirs; for (tmp = g_get_system_data_dirs (); ndirs < 10 && *tmp; tmp++) dirs [ndirs++] = g_build_filename (*tmp, CONF_PACKAGE, NULL); while (ndirs > 0) { ndirs--; GDir *dir = g_dir_open (dirs [ndirs], 0, NULL); if (dir) { GPatternSpec *ps = g_pattern_spec_new ("*.xml"); if (ps) { const gchar *fn; while ((fn = g_dir_read_name (dir))) { size_t sl = strlen (fn); if (g_pattern_match (ps, sl, fn, NULL)) { gchar *ffn = g_build_filename (dirs [ndirs], fn, NULL); /* Ignore errors */ Load (ffn); g_free (ffn); } } g_pattern_spec_free (ps); } g_dir_close (dir); } /* Free all paths except the first one which is held in db struct */ if (ndirs >= static_ndirs) g_free (dirs [ndirs]); } return LF_NO_ERROR; }
GtkBuilder *virt_viewer_util_load_ui(const char *name) { struct stat sb; GtkBuilder *builder; GError *error = NULL; builder = gtk_builder_new(); if (stat(name, &sb) >= 0) { gtk_builder_add_from_file(builder, name, &error); } else { gchar *path = g_build_filename(PACKAGE_DATADIR, "ui", name, NULL); gboolean success = (gtk_builder_add_from_file(builder, path, &error) != 0); if (error) { if (!(error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT)) g_warning("Failed to add ui file '%s': %s", path, error->message); g_clear_error(&error); } g_free(path); if (!success) { const gchar * const * dirs = g_get_system_data_dirs(); g_return_val_if_fail(dirs != NULL, NULL); while (dirs[0] != NULL) { path = g_build_filename(dirs[0], PACKAGE, "ui", name, NULL); if (gtk_builder_add_from_file(builder, path, NULL) != 0) { g_free(path); break; } g_free(path); dirs++; } if (dirs[0] == NULL) goto failed; } } if (error) { g_error("Cannot load UI description %s: %s", name, error->message); g_clear_error(&error); goto failed; } return builder; failed: g_error("failed to find UI description file"); g_object_unref(builder); return NULL; }
static void get_apps ( DRunModePrivateData *pd ) { get_apps_history ( pd ); gchar *dir; const gchar * const * sys = g_get_system_data_dirs (); for (; *sys != NULL; ++sys ) { dir = g_build_filename ( *sys, "applications", NULL ); walk_dir ( pd, dir ); g_free ( dir ); } dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL ); walk_dir ( pd, dir ); g_free ( dir ); }
static void miner_userguides_add_directories (TrackerMinerFS *fs) { const gchar * const *xdg_dirs; gint i; g_message ("Setting up userguides to iterate from XDG system directories"); /* Add all XDG system and local dirs */ xdg_dirs = g_get_system_data_dirs (); for (i = 0; xdg_dirs[i]; i++) { miner_userguides_basedir_add (fs, xdg_dirs[i]); } }
gboolean hotbabe_load_pics(void) { const gchar *const *sys = g_get_system_data_dirs(); for(const char *const *i = sys; *i; i++) { gchar *path = g_build_filename(*i, PNAME, bm.dir, NULL); gboolean r = load_anim(&bm.anim, path); g_free(path); if (r) return TRUE; } gchar *home = g_build_filename(g_get_user_data_dir(), PNAME, bm.dir, NULL); gboolean r2 = load_anim(&bm.anim, home); g_free(home); if (r2) return TRUE; return load_anim(&bm.anim, bm.dir); }
/* {{{ proto array Glib::systemDataDirs() Returns an ordered list of base directories in which to access system-wide application data. */ PHP_METHOD(Glib, systemDataDirs) { if (zend_parse_parameters_none() == FAILURE) { return; } const gchar* const *dir = g_get_system_data_dirs(); array_init(return_value); while (*dir != NULL) { add_next_index_string(return_value, *dir, 1); dir++; } }
static GdkPixbuf* load_icon_file( const char* file_name, int size ) { GdkPixbuf* icon = NULL; char* file_path; const gchar** dirs = (const gchar**) g_get_system_data_dirs(); const gchar** dir; for( dir = dirs; *dir; ++dir ) { file_path = g_build_filename( *dir, "pixmaps", file_name, NULL ); icon = gdk_pixbuf_new_from_file_at_scale( file_path, size, size, TRUE, NULL ); g_free( file_path ); if( icon ) break; } return icon; }
static void miner_applications_add_directories (TrackerMinerFS *fs) { #ifdef HAVE_MEEGOTOUCH TrackerIndexingTree *indexing_tree; GFile *file; const gchar *path; #endif /* HAVE_MEEGOTOUCH */ const gchar * const *xdg_dirs; const gchar *user_data_dir; gint i; g_message ("Setting up applications to iterate from XDG system directories"); /* Add all XDG system and local dirs */ xdg_dirs = g_get_system_data_dirs (); for (i = 0; xdg_dirs[i]; i++) { miner_applications_basedir_add (fs, xdg_dirs[i]); } g_message ("Setting up applications to iterate from XDG user directories"); user_data_dir = g_get_user_data_dir (); if (user_data_dir) { miner_applications_basedir_add (fs, user_data_dir); } #ifdef HAVE_MEEGOTOUCH /* NOTE: We don't use miner_applications_basedir_add() for * this location because it is unique to MeeGoTouch. */ path = "/usr/lib/duicontrolpanel/"; indexing_tree = tracker_miner_fs_get_indexing_tree (fs); g_message ("Setting up applications to iterate from MeegoTouch directories"); g_message (" Adding:'%s'", path); file = g_file_new_for_path (path); tracker_indexing_tree_add (indexing_tree, file, TRACKER_DIRECTORY_FLAG_RECURSE | TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_CHECK_MTIME); g_object_unref (file); #endif /* HAVE_MEEGOTOUCH */ }
static char* data_dir_foreach( DataDirFunc func, const char* mime_type, gpointer user_data ) { char* ret = NULL; const gchar* const * dirs; const char* dir = g_get_user_data_dir(); if( (ret = func( dir, mime_type, user_data )) ) return ret; dirs = g_get_system_data_dirs(); for( ; *dirs; ++dirs ) { if( (ret = func( *dirs, mime_type, user_data )) ) return ret; } return NULL; }