[gnome-continuous/wip/platform1.7: 2/3] fileutils: Support enumerating directories if matchDirs is true



commit 9a781e1709e2f8d95bd9037d10f9c93b2826c505
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]