[gnome-shell] [misc] add fileUtils.listDirAsync
- From: Maxim Ermilov <mermilov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] [misc] add fileUtils.listDirAsync
- Date: Thu, 30 Sep 2010 21:08:33 +0000 (UTC)
commit 4c068c135bd26e39c7064c880836d946d3bcb0aa
Author: Maxim Ermilov <zaspire rambler ru>
Date: Fri Oct 1 01:08:22 2010 +0400
[misc] add fileUtils.listDirAsync
Request information for a files from the directory asynchronously.
https://bugzilla.gnome.org/show_bug.cgi?id=623708
js/Makefile.am | 1 +
js/misc/fileUtils.js | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/js/Makefile.am b/js/Makefile.am
index 512be01..f35026e 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -3,6 +3,7 @@ jsdir = $(pkgdatadir)/js
nobase_dist_js_DATA = \
misc/docInfo.js \
+ misc/fileUtils.js \
misc/format.js \
misc/gnomeSession.js \
misc/params.js \
diff --git a/js/misc/fileUtils.js b/js/misc/fileUtils.js
new file mode 100644
index 0000000..4110041
--- /dev/null
+++ b/js/misc/fileUtils.js
@@ -0,0 +1,22 @@
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+
+function listDirAsync(file, callback) {
+ let allFiles = [];
+ file.enumerate_children_async(Gio.FILE_ATTRIBUTE_STANDARD_NAME,
+ Gio.FileQueryInfoFlags.NONE,
+ GLib.PRIORITY_LOW, null, function (obj, res) {
+ let enumerator = obj.enumerate_children_finish(res);
+ function onNextFileComplete(obj, res) {
+ let files = obj.next_files_finish(res);
+ if (files.length) {
+ allFiles = allFiles.concat(files);
+ enumerator.next_files_async(100, GLib.PRIORITY_LOW, null, onNextFileComplete);
+ } else {
+ enumerator.close(null);
+ callback(allFiles);
+ }
+ }
+ enumerator.next_files_async(100, GLib.PRIORITY_LOW, null, onNextFileComplete);
+ });
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]