GFileEnumerator * _g_local_file_enumerator_new (GLocalFile *file, const char *attributes, GFileQueryInfoFlags flags, GCancellable *cancellable, GError **error) { GLocalFileEnumerator *local; char *filename = g_file_get_path (G_FILE (file)); #ifdef USE_GDIR GError *dir_error; GDir *dir; dir_error = NULL; dir = g_dir_open (filename, 0, error != NULL ? &dir_error : NULL); if (dir == NULL) { if (error != NULL) { convert_file_to_io_error (error, dir_error); g_error_free (dir_error); } g_free (filename); return NULL; } #else DIR *dir; int errsv; dir = opendir (filename); if (dir == NULL) { errsv = errno; g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv), g_strerror (errsv)); g_free (filename); return NULL; } #endif local = g_object_new (G_TYPE_LOCAL_FILE_ENUMERATOR, "container", file, NULL); local->dir = dir; local->filename = filename; local->matcher = g_file_attribute_matcher_new (attributes); #ifndef USE_GDIR local->reduced_matcher = g_file_attribute_matcher_subtract_attributes (local->matcher, G_LOCAL_FILE_INFO_NOSTAT_ATTRIBUTES"," "standard::type"); #endif local->flags = flags; return G_FILE_ENUMERATOR (local); }
GFileEnumerator * _g_local_file_enumerator_new (const char *filename, const char *attributes, GFileQueryInfoFlags flags, GCancellable *cancellable, GError **error) { GLocalFileEnumerator *local; #ifdef USE_GDIR GError *dir_error; GDir *dir; dir_error = NULL; dir = g_dir_open (filename, 0, error != NULL ? &dir_error : NULL); if (dir == NULL) { if (error != NULL) { convert_file_to_io_error (error, dir_error); g_error_free (dir_error); } return NULL; } #else DIR *dir; int errsv; dir = opendir (filename); if (dir == NULL) { errsv = errno; g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), "%s", g_strerror (errsv)); return NULL; } #endif local = g_object_new (G_TYPE_LOCAL_FILE_ENUMERATOR, NULL); local->dir = dir; local->filename = g_strdup (filename); local->matcher = g_file_attribute_matcher_new (attributes); local->flags = flags; return G_FILE_ENUMERATOR (local); }