From 54e41eee0b319a58600752fb89f885f6e16a3bcd Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Mon, 4 May 2009 17:14:10 +0300 Subject: [PATCH] Fetch files from enumerator, asynchronously This is the second (and hopefully) last step towards async plugin loading. --- src/rygel/rygel-plugin-loader.vala | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/rygel/rygel-plugin-loader.vala b/src/rygel/rygel-plugin-loader.vala index 4d1640f..4b280ad 100644 --- a/src/rygel/rygel-plugin-loader.vala +++ b/src/rygel/rygel-plugin-loader.vala @@ -72,9 +72,29 @@ public class Rygel.PluginLoader : Object { return; } - FileInfo info; + enumerator.next_files_async (int.MAX, + Priority.DEFAULT, + null, + on_next_files_enumerated); + } + + private void on_next_files_enumerated (GLib.Object source_object, + GLib.AsyncResult res) { + FileEnumerator enumerator = (FileEnumerator) source_object; + File dir = (File) enumerator.get_container (); + + List infos; + try { + infos = enumerator.next_files_finish (res); + } catch (Error error) { + critical ("Error listing contents of directory '%s': %s\n", + dir.get_path (), + error.message); + + return; + } - while ((info = enumerator.next_file (null)) != null) { + foreach (var info in infos) { string file_name = info.get_name (); string file_path = Path.build_filename (dir.get_path (), file_name); -- 2.7.4