[gnome-continuous/wip/platform: 6/9] fileutils: Support enumerating directories if matchDirs is true
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous/wip/platform: 6/9] fileutils: Support enumerating directories if matchDirs is true
- Date: Fri, 12 Sep 2014 13:58:00 +0000 (UTC)
commit 961eb66813d081f89d79c0b84cfe46f80137a891
Author: Alexander Larsson <alexl redhat com>
Date: Fri Sep 12 13:25:18 2014 +0200
fileutils: Support enumerating directories if matchDirs is true
This is needed as i want to use walkDir to clean up stuff, including
directories.
src/js/fileutil.js | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/js/fileutil.js b/src/js/fileutil.js
index 87191bf..00ad6ac 100644
--- a/src/js/fileutil.js
+++ b/src/js/fileutil.js
@@ -20,7 +20,7 @@ const Gio = imports.gi.Gio;
const Params = imports.params;
-function walkDirInternal(dir, matchParams, callback, cancellable, queryStr, depth, sortByName) {
+function walkDirInternal(dir, matchParams, callback, cancellable, queryStr, depth, sortByName, matchDirs) {
let denum = dir.enumerate_children(queryStr, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
cancellable);
let info;
@@ -71,7 +71,11 @@ function walkDirInternal(dir, matchParams, callback, cancellable, queryStr, dept
});
}
for (let i = 0; i < subdirs.length; i++) {
- walkDirInternal(subdirs[i], matchParams, callback, cancellable, queryStr, depth);
+ walkDirInternal(subdirs[i], matchParams, callback, cancellable, queryStr, depth, matchDirs);
+ }
+
+ if (matchDirs) {
+ callback(dir, cancellable);
}
}
@@ -80,10 +84,11 @@ function walkDir(dir, matchParams, callback, cancellable) {
fileType: null,
contentType: null,
depth: -1,
- sortByName: false });
+ sortByName: false,
+ matchDirs: false});
let queryStr = 'standard::name,standard::type,unix::mode';
if (matchParams.contentType)
queryStr += ',standard::fast-content-type';
let depth = matchParams.depth;
- walkDirInternal(dir, matchParams, callback, cancellable, queryStr, depth, matchParams.sortByName);
+ walkDirInternal(dir, matchParams, callback, cancellable, queryStr, depth, matchParams.sortByName,
matchParams.matchDirs);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]