[gnome-games] directory: Add async version of foreach
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] directory: Add async version of foreach
- Date: Fri, 22 Jun 2018 20:06:48 +0000 (UTC)
commit 3c97991f7ba89f38a540e022c2dcd09c8da2efb4
Author: theawless <theawless gmail com>
Date: Tue Jun 19 23:25:37 2018 +0530
directory: Add async version of foreach
This adds the possibility of walking through files of a directory
asynchronously.
https://gitlab.gnome.org/GNOME/gnome-games/issues/11
src/utils/directory.vala | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/src/utils/directory.vala b/src/utils/directory.vala
index 66a0cae..053d0ab 100644
--- a/src/utils/directory.vala
+++ b/src/utils/directory.vala
@@ -15,4 +15,17 @@ public class Games.Directory : Object {
if (file_info_test (file_info))
return;
}
+
+ public async void @foreach_async (string attributes, FileInfoTest file_info_test) throws Error {
+ var enumerator = yield file.enumerate_children_async (attributes, FileQueryInfoFlags.NONE);
+ while (true) {
+ var file_infos = yield enumerator.next_files_async (25);
+ if (file_infos == null || file_infos.length () == 0)
+ break;
+
+ foreach (var file_info in file_infos)
+ if (file_info_test (file_info))
+ return;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]