static GList * get_description_files (GFile *dir) { GFileEnumerator *enumerator; GFileInfo *info; GFile *desc_file; GList *files; const gchar *name; enumerator = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (!enumerator) { return NULL; } files = NULL; while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { name = g_file_info_get_name (info); if (g_str_has_suffix (name, ".description")) { desc_file = g_file_enumerator_get_child (enumerator, info); files = g_list_insert_sorted (files, desc_file, compare_files); } g_object_unref (info); } g_object_unref (enumerator); return files; }
int main (int argc, char **argv) { GFile *dir; GFileEnumerator *fenum; GFileInfo *info; GError *error = NULL; g_type_init(); dir = g_file_new_for_uri ("file:///home/gabriel/Fotos/Festa%20D%C3%A9ia"); fenum = g_file_enumerate_children (dir, "*", G_FILE_QUERY_INFO_NONE, NULL, &error); if (error) g_printerr ("FUDEU: %s\n", error->message); while ((info = g_file_enumerator_next_file(fenum, NULL, NULL))){ g_print ("LISTANDO: %s\n", g_file_info_get_name (info)); g_object_unref (info); } return 0; }
static int run_all_tests (int argc, char **argv) { GFile *dir, *file; GFileInfo *info; GFileEnumerator *children; GList *list = NULL; dir = g_file_new_for_path ("uri"); children = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, NULL); while ((info = g_file_enumerator_next_file (children, NULL, NULL))) { const gchar *name = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME); if (!g_str_has_suffix (name, ".test")) continue; list = g_list_insert_sorted (list, (gchar *) name, (GCompareFunc) strcmp); } while (list) { gchar *test_id = g_strconcat ("/", list->data, NULL); file = g_file_get_child (dir, list->data); g_test_add_data_func (test_id, file, run_test); g_free (test_id); list = g_list_delete_link (list, list); } return g_test_run (); }
static void rb_psp_source_create_playlists (RBGenericPlayerSource *source) { GMount *mount; GFile *music_dir; g_object_get (source, "mount", &mount, NULL); music_dir = find_music_dir (mount); g_object_unref (mount); if (music_dir != NULL) { GFileEnumerator *e; GFileInfo *info; e = g_file_enumerate_children (music_dir, G_FILE_ATTRIBUTE_STANDARD_NAME","G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (e != NULL) { while ((info = g_file_enumerator_next_file (e, NULL, NULL)) != NULL) { GFile *file; const char *name; if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY) { g_object_unref (info); continue; } name = g_file_info_get_name (info); file = g_file_resolve_relative_path (music_dir, name); visit_playlist_dirs (RB_PSP_SOURCE (source), file); g_object_unref (file); g_object_unref (info); } g_object_unref (e); } g_object_unref (music_dir); } }
gboolean _rpmostree_util_enumerate_directory_allow_noent (GFile *dirpath, const char *queryargs, GFileQueryInfoFlags queryflags, GFileEnumerator **out_direnum, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; GError *temp_error = NULL; gs_unref_object GFileEnumerator *ret_direnum = NULL; ret_direnum = g_file_enumerate_children (dirpath, queryargs, queryflags, cancellable, &temp_error); if (!ret_direnum) { if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { g_clear_error (&temp_error); ret = TRUE; } else g_propagate_error (error, temp_error); goto out; } ret = TRUE; gs_transfer_out_value (out_direnum, &ret_direnum); out: return ret; }
static GFileEnumerator * gnac_profiles_mgr_get_default_profiles_enumerator(void) { GFile *dir = g_file_new_for_path(PKGDATADIR "/profiles/default"); if (!g_file_query_exists(dir, NULL)) { libgnac_warning("%s", _("Unable to find the default profiles directory")); return NULL; } GError *error = NULL; GFileEnumerator *files = g_file_enumerate_children(dir, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, &error); if (!files) { libgnac_warning("%s: %s", _("Unable to browse the default profiles directory"), error->message); g_clear_error(&error); g_object_unref(dir); return NULL; } g_object_unref(dir); return files; }
/*Recursively delete the file.*/ void codeslayer_utils_file_delete (GFile *file, GError **error) { GFileEnumerator *enumerator; enumerator = g_file_enumerate_children (file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (enumerator != NULL) { GFileInfo *file_info; while ((file_info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { GFile *child; const char *file_name = g_file_info_get_name (file_info); child = g_file_get_child (file, file_name); if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) codeslayer_utils_file_delete (child, error); g_file_delete (child, NULL, error); g_object_unref(child); g_object_unref (file_info); } g_object_unref (enumerator); } g_file_delete (file, NULL, error); }
/** * Call back for the g_slist_foreach function that carves one directory * and sub directories in a recursive way. * @param data is an element of opt->list ie: a gchar * that represents * a directory name * @param user_data is the main_struct_t * pointer to the main structure. */ static void carve_one_directory(gpointer data, gpointer user_data) { gchar *directory = (gchar *) data; main_struct_t *main_struct = (main_struct_t *) user_data; GFile *a_dir = NULL; GFileEnumerator *file_enum = NULL; GError *error = NULL; if (directory != NULL && main_struct != NULL) { a_dir = g_file_new_for_path(directory); file_enum = g_file_enumerate_children(a_dir, "*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &error); if (error == NULL && file_enum != NULL) { iterate_over_enum(main_struct, directory, file_enum); g_file_enumerator_close(file_enum, NULL, NULL); file_enum = free_object(file_enum); } else { print_error(__FILE__, __LINE__, _("Unable to enumerate directory %s: %s\n"), directory, error->message); error = free_error(error); } a_dir = free_object(a_dir); } }
static void updater_find_sub_directories (updater_t *updater, GFile *file) { GFileEnumerator *enumerator; GFileInfo *info; GError *err = NULL; g_return_if_fail (updater); g_return_if_fail (file); enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, &err); g_clear_error (&err); while ((info = g_file_enumerator_next_file (enumerator, NULL, &err)) != NULL) { const gchar *name; GFile *child; name = g_file_info_get_name (info); child = g_file_get_child (file, name); g_object_unref (info); updater_add_watcher (updater, child); g_object_unref (child); } g_object_unref (enumerator); }
static gboolean xplayer_pl_parser_load_directory (GFile *file, GList **list, gboolean *unhandled) { GFileEnumerator *e; GFileInfo *info; GError *err = NULL; *list = NULL; *unhandled = FALSE; e = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, &err); if (e == NULL) { if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED) != FALSE) *unhandled = TRUE; g_error_free (err); return FALSE; } while ((info = g_file_enumerator_next_file (e, NULL, NULL)) != NULL) *list = g_list_prepend (*list, info); g_file_enumerator_close (e, NULL, NULL); g_object_unref (e); return TRUE; }
static void _delete_trash_file (GFile *file, gboolean del_file, gboolean del_children) { GFileInfo *info; GFile *child; GFileEnumerator *enumerator; if (del_children) { enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (enumerator) { while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { child = g_file_get_child (file, g_file_info_get_name (info)); _delete_trash_file (child, TRUE, g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY); g_object_unref (child); g_object_unref (info); } g_file_enumerator_close (enumerator, NULL, NULL); g_object_unref (enumerator); } } if (del_file) { g_file_delete (file, NULL, NULL); } }
static gboolean xmms_gvfs_browse (xmms_xform_t *xform, const gchar *url, xmms_error_t *error) { GError *err = NULL; GFile *file; GFileInfo *info; GFileEnumerator *enumerator; /* Same hack as in _init */ if (!g_ascii_strncasecmp (url, "file://", 7)) { file = g_file_new_for_path (url+7); } else { file = g_file_new_for_uri (url); } enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &err); g_object_unref (file); if (!enumerator) { xmms_error_set (error, XMMS_ERROR_GENERIC, err->message); return FALSE; } while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL))) { guint32 child_type, flags = 0; guint64 child_size; const gchar *child_name; child_name = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME); child_type = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE); child_size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE); if (child_type & G_FILE_TYPE_DIRECTORY) { flags |= XMMS_XFORM_BROWSE_FLAG_DIR; } xmms_xform_browse_add_entry (xform, child_name, flags); if (~child_type & G_FILE_TYPE_DIRECTORY) { xmms_xform_browse_add_entry_property_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_SIZE, child_size); } g_object_unref (info); } g_file_enumerator_close (enumerator, NULL, NULL); return TRUE; }
QStringList Dir::m_entry_list() { QStringList entries; if(m_info->isDir()) { GError *err = NULL; GFileEnumerator *enumerator = g_file_enumerate_children(m_file, "*", G_FILE_QUERY_INFO_NONE, NULL, &err); if(!enumerator) { g_object_unref(enumerator); return entries; } for(GFileInfo *info = g_file_enumerator_next_file(enumerator, NULL, &err); !(info == 0); info = g_file_enumerator_next_file(enumerator , NULL, &err)) { entries.append(QString(g_file_get_uri(m_file)) + "/" + QString(g_file_info_get_name(info))); g_object_unref(info); } g_file_enumerator_close(enumerator, NULL, &err); g_object_unref(enumerator); } return entries; }
static gboolean read_all_children (char *filename, const char *attributes, GList **list_out) { GFileEnumerator *enumerator; GList *list; GFile *file; GFileInfo *info; file = g_file_new_for_path (filename); enumerator = g_file_enumerate_children (file, attributes, 0, NULL, NULL); if (enumerator == NULL) { return FALSE; } list = NULL; do { info = g_file_enumerator_next_file (enumerator, NULL, NULL); if (info) { list = g_list_prepend (list, info); } } while (info != NULL); g_object_unref (enumerator); g_object_unref (file); *list_out = g_list_reverse (list); return TRUE; }
static void directory_foreach (GFile *file, gchar *suffix, GFunc func, gpointer user_data) { GFileEnumerator *enumerator; GFileInfo *info; GFile *child; enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (!enumerator) { return; } while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { if (!suffix || g_str_has_suffix (g_file_info_get_name (info), suffix)) { child = g_file_enumerator_get_child (enumerator, info); (func) (child, user_data); g_object_unref (child); } g_object_unref (info); } g_object_unref (enumerator); }
/* Asserts that all files in @included are also in @including */ static void scan_directory (GFile *directory, FileScannedCallback scanned_callback, gpointer callback_data) { GQueue *files; GQueue *file_infos; GFileEnumerator *enumerator; files = g_queue_new (); file_infos = g_queue_new (); g_queue_push_tail (files, g_object_ref (directory)); g_queue_push_tail (file_infos, g_file_query_info (directory, G_FILE_ATTRIBUTE_STANDARD_NAME"," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL)); while (!g_queue_is_empty (files)) { g_autoptr (GFile) file; g_autoptr (GFileInfo) file_info; file = g_queue_pop_tail (files); file_info = g_queue_pop_tail (file_infos); if (scanned_callback) { scanned_callback (file, file_info, callback_data); } if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) { enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME"," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (enumerator) { GFile *child; GFileInfo *child_info; child_info = g_file_enumerator_next_file (enumerator, NULL, NULL); while (child_info != NULL) { child = g_file_get_child (file, g_file_info_get_name (child_info)); g_queue_push_tail (files, child); g_queue_push_tail (file_infos, child_info); child_info = g_file_enumerator_next_file (enumerator, NULL, NULL); } g_object_unref (enumerator); } } } g_queue_free_full (files, g_object_unref); g_queue_free_full (file_infos, g_object_unref); }
void test_utils_add_test_for_all_files (const gchar *prefix, GFile *base, GFile *file, GTestDataFunc test_func, AddTestFunc add_test_func) { GFileEnumerator *enumerator; GFileInfo *info; GList *l, *files; GError *error = NULL; if (g_file_query_file_type (file, 0, NULL) != G_FILE_TYPE_DIRECTORY) { gchar *test_path; gchar *relative_path; if (base) relative_path = g_file_get_relative_path (base, file); else relative_path = g_file_get_path (file); test_path = g_strconcat (prefix, "/", relative_path, NULL); g_test_add_data_func_full (test_path, g_object_ref (file), test_func, g_object_unref); return; } enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &error); g_assert_no_error (error); files = NULL; while ((info = g_file_enumerator_next_file (enumerator, NULL, &error))) { GFile *next_file = g_file_get_child (file, g_file_info_get_name (info)); if (add_test_func == NULL || add_test_func (next_file)) { files = g_list_prepend (files, g_object_ref (next_file)); } g_object_unref (next_file); g_object_unref (info); } g_assert_no_error (error); g_object_unref (enumerator); files = g_list_sort (files, compare_files); for (l = files; l; l = l->next) { test_utils_add_test_for_all_files (prefix, base, l->data, test_func, add_test_func); } g_list_free_full (files, g_object_unref); }
static GArray * _get_ref_frame_cache (GstValidateSsim * self, const gchar * ref_file) { GFile *ref_dir_file = NULL; GFileInfo *info; GFileEnumerator *fenum; GArray *frames = NULL; gchar *ref_dir = NULL; ref_dir = g_path_get_dirname (ref_file); frames = g_hash_table_lookup (self->priv->ref_frames_cache, ref_file); if (frames) goto done; ref_dir_file = g_file_new_for_path (ref_dir); if (!(fenum = g_file_enumerate_children (ref_dir_file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, NULL))) { GST_INFO ("%s is not a folder", ref_dir); goto done; } for (info = g_file_enumerator_next_file (fenum, NULL, NULL); info; info = g_file_enumerator_next_file (fenum, NULL, NULL)) { Frame iframe; const gchar *display_name = g_file_info_get_display_name (info); if (!_filename_get_timestamp (self, display_name, &iframe.ts)) { g_object_unref (info); continue; } iframe.path = g_build_path (G_DIR_SEPARATOR_S, ref_dir, g_file_info_get_name (info), NULL); g_object_unref (info); if (!frames) { frames = g_array_new (TRUE, TRUE, sizeof (Frame)); g_array_set_clear_func (frames, (GDestroyNotify) _free_frame); } g_array_append_val (frames, iframe); } if (frames) { g_array_sort (frames, (GCompareFunc) _sort_frames); g_hash_table_insert (self->priv->ref_frames_cache, g_strdup (ref_dir), frames); } done: g_clear_object (&ref_dir_file); g_free (ref_dir); return frames; }
/** * ostree_repo_checkout_gc: * @self: Repo * @cancellable: Cancellable * @error: Error * * Call this after finishing a succession of checkout operations; it * will delete any currently-unused uncompressed objects from the * cache. */ gboolean ostree_repo_checkout_gc (OstreeRepo *self, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; g_autoptr(GHashTable) to_clean_dirs = NULL; GHashTableIter iter; gpointer key, value; g_mutex_lock (&self->cache_lock); to_clean_dirs = self->updated_uncompressed_dirs; self->updated_uncompressed_dirs = g_hash_table_new (NULL, NULL); g_mutex_unlock (&self->cache_lock); if (to_clean_dirs) g_hash_table_iter_init (&iter, to_clean_dirs); while (to_clean_dirs && g_hash_table_iter_next (&iter, &key, &value)) { g_autoptr(GFile) objdir = NULL; g_autoptr(GFileEnumerator) enumerator = NULL; g_autofree char *objdir_name = NULL; objdir_name = g_strdup_printf ("%02x", GPOINTER_TO_UINT (key)); objdir = g_file_get_child (self->uncompressed_objects_dir, objdir_name); enumerator = g_file_enumerate_children (objdir, "standard::name,standard::type,unix::inode,unix::nlink", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error); if (!enumerator) goto out; while (TRUE) { GFileInfo *file_info; guint32 nlinks; if (!gs_file_enumerator_iterate (enumerator, &file_info, NULL, cancellable, error)) goto out; if (file_info == NULL) break; nlinks = g_file_info_get_attribute_uint32 (file_info, "unix::nlink"); if (nlinks == 1) { g_autoptr(GFile) objpath = NULL; objpath = g_file_get_child (objdir, g_file_info_get_name (file_info)); if (!gs_file_unlink (objpath, cancellable, error)) goto out; } } } ret = TRUE; out: return ret; }
bool recursive_delete_path( GFile * file ) { bool result = false; GFileInfo * info = g_file_query_info( file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL ); if ( info ) { if ( g_file_info_get_file_type( info ) == G_FILE_TYPE_DIRECTORY ) { GFileEnumerator * enumerator = g_file_enumerate_children( file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL ); if ( enumerator ) { while ( true ) { GError * error = NULL; GFileInfo * child_info = g_file_enumerator_next_file( enumerator, NULL, &error ); if ( ! child_info ) { g_clear_error( &error ); break; } GFile * child = g_file_resolve_relative_path( file, g_file_info_get_name( child_info ) ); bool child_deleted = recursive_delete_path( child ); g_object_unref( G_OBJECT( child_info ) ); g_object_unref( G_OBJECT( child ) ); if ( ! child_deleted ) { break; } } g_object_unref( G_OBJECT( enumerator ) ); } } g_object_unref( G_OBJECT( info ) ); gchar * s = g_file_get_path( file ); g_debug( "DELETING '%s'", s ); g_free( s ); // Will delete the file or directory result = g_file_delete( file, NULL, NULL ); } return result; }
static gboolean list_all_deployment_directories (OstreeSysroot *self, GPtrArray **out_deployments, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; gs_unref_object GFileEnumerator *dir_enum = NULL; gs_unref_object GFile *deploydir = NULL; gs_unref_ptrarray GPtrArray *ret_deployments = NULL; GError *temp_error = NULL; deploydir = g_file_resolve_relative_path (self->path, "ostree/deploy"); ret_deployments = g_ptr_array_new_with_free_func (g_object_unref); dir_enum = g_file_enumerate_children (deploydir, OSTREE_GIO_FAST_QUERYINFO, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, &temp_error); if (!dir_enum) { if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { g_clear_error (&temp_error); goto done; } else { g_propagate_error (error, temp_error); goto out; } } while (TRUE) { GFileInfo *file_info = NULL; GFile *child = NULL; if (!gs_file_enumerator_iterate (dir_enum, &file_info, &child, NULL, error)) goto out; if (file_info == NULL) break; if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_DIRECTORY) continue; if (!_ostree_sysroot_list_deployment_dirs_for_os (child, ret_deployments, cancellable, error)) goto out; } done: ret = TRUE; ot_transfer_out_value (out_deployments, &ret_deployments); out: return ret; }
static GFile * find_dir_no_case (GFile *root, gboolean look_for_psp) { GFileEnumerator *e; GFileInfo *info; GFile *ret; GFile *music_dir; ret = music_dir = NULL; e = g_file_enumerate_children (root, G_FILE_ATTRIBUTE_STANDARD_NAME","G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (e == NULL) return ret; while ((info = g_file_enumerator_next_file (e, NULL, NULL)) != NULL) { const char *name; name = g_file_info_get_name (info); if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY) { g_object_unref (info); continue; } if (g_ascii_strcasecmp (name, "MUSIC") == 0) { music_dir = g_file_resolve_relative_path (root, name); g_object_unref (info); if (look_for_psp) continue; else break; } if (look_for_psp) { if (g_ascii_strcasecmp (name, "PSP") == 0) { GFile *psp_dir; psp_dir = g_file_resolve_relative_path (root, name); ret = find_dir_no_case (psp_dir, FALSE); g_object_unref (psp_dir); if (ret != NULL) { g_object_unref (info); if (music_dir != NULL) g_object_unref (music_dir); music_dir = NULL; break; } } } g_object_unref (info); } g_object_unref (e); if (ret == NULL) ret = music_dir; return ret; }
/* Search the documentation pages for the string 'text', building the index if necessary */ void i7_search_window_search_documentation(I7SearchWindow *self) { GError *err; if(doc_index == NULL) { /* documentation index hasn't been built yet */ GFile *doc_file = i7_app_get_data_file_va(i7_app_get(), "Documentation", NULL); GFileEnumerator *docdir; if((docdir = g_file_enumerate_children(doc_file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &err)) == NULL) { IO_ERROR_DIALOG(GTK_WINDOW(self), doc_file, err, _("opening documentation directory")); g_object_unref(doc_file); return; } start_spinner(self); GFileInfo *info; while((info = g_file_enumerator_next_file(docdir, NULL, &err)) != NULL) { const char *basename = g_file_info_get_name(info); const char *displayname = g_file_info_get_display_name(info); if(!g_str_has_suffix(basename, ".html") || (!g_str_has_prefix(basename, "doc") && !g_str_has_prefix(basename, "Rdoc"))) continue; char *label = g_strdup_printf(_("Please be patient, indexing %s..."), displayname); gtk_label_set_text(GTK_LABEL(self->search_text), label); g_free(label); while(gtk_events_pending()) gtk_main_iteration(); GFile *file = g_file_get_child(doc_file, basename); GSList *doctexts = html_to_ascii(file, g_str_has_prefix(basename, "R")); g_object_unref(file); if(doctexts != NULL) { GSList *iter; /* Append the entries to the documentation index and search them right now while we're at it */ for(iter = doctexts; iter != NULL; iter = g_slist_next(iter)) { doc_index = g_list_prepend(doc_index, iter->data); search_documentation(iter->data, self); } g_slist_free(doctexts); } } g_object_unref(doc_file); stop_spinner(self); update_label(self); } else { start_spinner(self); g_list_foreach(doc_index, (GFunc)search_documentation, self); stop_spinner(self); } return; }
void locke_appmanager_scan_for_deploys(LockeAppManager *lam, GFile *deployDir) { if (g_file_query_file_type(deployDir, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) { g_log(LSVR_DOMAIN, G_LOG_LEVEL_WARNING, "Hey, autodeploy dir '%s' does not exist!! Create it to be able to make deploys. ", g_file_get_path(deployDir)); return; } g_log(LSVR_DOMAIN, G_LOG_LEVEL_INFO, "Scanning folder '%s' for application deployments", g_file_get_path(deployDir)); /* Get file enumerator */ GError *err = NULL; GFileEnumerator *files = g_file_enumerate_children(deployDir, "*", G_FILE_QUERY_INFO_NONE, NULL, &err); if (err != NULL) { /* Report error to user, and free error */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_ERROR, "Unable to get file list for directory '%s': %s", g_file_get_path(deployDir), err->message); g_error_free(err); goto scan_for_deploys_finally; } /* process each file individually */ GFileInfo *fileInfo = NULL; do { fileInfo = g_file_enumerator_next_file(files, NULL, &err); if (err != NULL) { /* Report error to user, and free error */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_ERROR, "Unable to get file for directory '%s': %s", g_file_get_path(deployDir), err->message); g_error_free(err); goto scan_for_deploys_finally; } /* stop condition */ if (fileInfo == NULL) break; /* finally, process the file */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_INFO, " =========> Processing file '%s'", g_file_info_get_display_name(fileInfo)); locke_appmanager_add_application(lam, g_file_get_path(deployDir), g_file_info_get_name(fileInfo)); } while (TRUE); /* Close open things */ g_file_enumerator_close(files, NULL, &err); if (err != NULL) { /* Report error to user, and free error */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_ERROR, "Error closing file enumerator for directory '%s': %s", g_file_get_path(deployDir), err->message); g_error_free(err); goto scan_for_deploys_finally; } /* Free allocated memory */ scan_for_deploys_finally: g_object_unref(files); }
static GList * ephy_web_application_get_application_list_internal (gboolean only_legacy) { GFileEnumerator *children = NULL; GFileInfo *info; GList *applications = NULL; g_autofree char *parent_directory_path = NULL; g_autoptr(GFile) parent_directory = NULL; if (only_legacy) parent_directory_path = g_build_filename (g_get_user_config_dir (), "epiphany", NULL); else parent_directory_path = g_strdup (g_get_user_data_dir ()); parent_directory = g_file_new_for_path (parent_directory_path); children = g_file_enumerate_children (parent_directory, "standard::name", 0, NULL, NULL); if (!children) return NULL; info = g_file_enumerator_next_file (children, NULL, NULL); while (info) { const char *name; name = g_file_info_get_name (info); if ((only_legacy && g_str_has_prefix (name, "app-")) || (!only_legacy && g_str_has_prefix (name, EPHY_WEB_APP_PROGRAM_NAME_PREFIX))) { EphyWebApplication *app; char *profile_dir; profile_dir = g_build_filename (parent_directory_path, name, NULL); app = ephy_web_application_for_profile_directory (profile_dir); if (app) { if (!only_legacy) { g_autofree char *app_file = g_build_filename (profile_dir, ".app", NULL); if (g_file_test (app_file, G_FILE_TEST_EXISTS)) applications = g_list_prepend (applications, app); else g_object_unref (app); } else applications = g_list_prepend (applications, app); } g_free (profile_dir); } g_object_unref (info); info = g_file_enumerator_next_file (children, NULL, NULL); } g_object_unref (children); return g_list_reverse (applications); }
static gboolean nautilus_disc_burn_is_empty (GtkWindow *toplevel) { GFileEnumerator *enumerator; GFileInfo *info = NULL; GError *error = NULL; GFile *file; file = g_file_new_for_uri (BURN_URI); enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, &error); if (!enumerator) { gchar *string; DEBUG_PRINT ("Could not open burn uri %s: %s\n", uri, error->message); if (!toplevel) { g_error_free (error); return TRUE; } string = g_strdup_printf ("%s.", _("An internal error occurred")); brasero_utils_message_dialog (GTK_WIDGET (toplevel), string, error ? error->message:NULL, GTK_MESSAGE_ERROR); g_free (string); g_object_unref (file); g_error_free (error); return TRUE; } info = g_file_enumerator_next_file (enumerator, NULL, NULL); g_object_unref (enumerator); g_object_unref (file); if (!info) { if (!toplevel) return TRUE; brasero_utils_message_dialog (GTK_WIDGET (toplevel), _("Please add files."), _("There are no files to write to disc"), GTK_MESSAGE_ERROR); return TRUE; } g_object_unref (info); return FALSE; }
static gboolean relabel_recursively (OstreeSePolicy *sepolicy, GFile *dir, GFileInfo *dir_info, GPtrArray *path_parts, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; g_autoptr(GFileEnumerator) direnum = NULL; if (!relabel_one_path (sepolicy, dir, dir_info, path_parts, cancellable, error)) goto out; direnum = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error); if (!direnum) goto out; while (TRUE) { GFileInfo *file_info; GFile *child; GFileType ftype; if (!gs_file_enumerator_iterate (direnum, &file_info, &child, cancellable, error)) goto out; if (file_info == NULL) break; g_ptr_array_add (path_parts, (char*)gs_file_get_basename_cached (child)); ftype = g_file_info_get_file_type (file_info); if (ftype == G_FILE_TYPE_DIRECTORY) { if (!relabel_recursively (sepolicy, child, file_info, path_parts, cancellable, error)) goto out; } else { if (!relabel_one_path (sepolicy, child, file_info, path_parts, cancellable, error)) goto out; } g_ptr_array_remove_index (path_parts, path_parts->len - 1); } ret = TRUE; out: return ret; }
static gboolean dir_project_list_directory (DirProject *project, DirGroup* parent, GError **error) { gboolean ok; GFileEnumerator *enumerator; enumerator = g_file_enumerate_children (DIR_GROUP_DATA (parent)->base.directory, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, error); ok = enumerator != NULL; if (ok) { GFileInfo *info; while ((info = g_file_enumerator_next_file (enumerator, NULL, error)) != NULL) { const gchar *name; GFile *file; name = g_file_info_get_name (info); file = g_file_get_child (DIR_GROUP_DATA (parent)->base.directory, name); g_object_unref (info); /* Check if file is a source */ if (!dir_pattern_stack_is_match (project->sources, file)) continue; if (g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY) { /* Create a group for directory */ DirGroup *group; group = dir_group_new (file); g_hash_table_insert (project->groups, g_file_get_uri (file), group); anjuta_project_node_append (parent, group); ok = dir_project_list_directory (project, group, error); if (!ok) break; } else { /* Create a source for files */ DirSource *source; source = dir_source_new (file); anjuta_project_node_append (parent, source); } } g_file_enumerator_close (enumerator, NULL, NULL); g_object_unref (enumerator); } return ok; }
static void aod_update_option_list (LoadOptionsDialogData *aod_data) { GtkListStore *list_store = GTK_LIST_STORE (aod_data->aod_model); GFile *options_dir; GFileEnumerator *file_enum; GFileInfo *info; GError *err = NULL; gtk_list_store_clear (list_store); options_dir = get_user_config_subdirectory (ADD_FOLDER_OPTIONS_DIR, TRUE); make_directory_tree (options_dir, 0700, NULL); file_enum = g_file_enumerate_children (options_dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &err); if (err != NULL) { g_warning ("Failed to enumerate children: %s", err->message); g_clear_error (&err); g_object_unref (options_dir); return; } while ((info = g_file_enumerator_next_file (file_enum, NULL, &err)) != NULL) { const char *name; char *display_name; GtkTreeIter iter; if (err != NULL) { g_warning ("Failed to get info while enumerating: %s", err->message); g_clear_error (&err); continue; } name = g_file_info_get_name (info); display_name = g_filename_display_name (name); gtk_list_store_append (GTK_LIST_STORE (aod_data->aod_model), &iter); gtk_list_store_set (GTK_LIST_STORE (aod_data->aod_model), &iter, 0, name, 1, display_name, -1); g_free (display_name); g_object_unref (info); } if (err != NULL) { g_warning ("Failed to get info after enumeration: %s", err->message); g_clear_error (&err); } g_object_unref (options_dir); }
static gboolean find_metatests_in_directory (GFile *directory, GPtrArray *results, GError **error) { GFileEnumerator *enumerator = g_file_enumerate_children (directory, "standard::name,standard::type", G_FILE_QUERY_INFO_NONE, NULL, error); if (!enumerator) return FALSE; while (*error == NULL) { GFileInfo *info = g_file_enumerator_next_file (enumerator, NULL, error); if (info == NULL) break; GFile *child = g_file_enumerator_get_child (enumerator, info); switch (g_file_info_get_file_type (info)) { case G_FILE_TYPE_REGULAR: { const char *name = g_file_info_get_name (info); if (g_str_has_suffix (name, ".metatest")) g_ptr_array_add (results, g_file_get_path (child)); break; } case G_FILE_TYPE_DIRECTORY: find_metatests_in_directory (child, results, error); break; default: break; } g_object_unref (child); g_object_unref (info); } { GError *tmp_error = NULL; if (!g_file_enumerator_close (enumerator, NULL, &tmp_error)) { if (*error != NULL) g_clear_error (&tmp_error); else g_propagate_error (error, tmp_error); } } g_object_unref (enumerator); return *error == NULL; }