[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 16390ac 1/5: In path-iterator, add new function and test
From: |
Stephen Leake |
Subject: |
[elpa] master 16390ac 1/5: In path-iterator, add new function and test |
Date: |
Fri, 1 Feb 2019 18:12:04 -0500 (EST) |
branch: master
commit 16390ac2b8c0622ae94d6917f2df0ca90d61ec55
Author: Stephen Leake <address@hidden>
Commit: Stephen Leake <address@hidden>
In path-iterator, add new function and test
* packages/path-iterator/path-iterator-test.el (path-iter-all-files): New
test.
* packages/path-iterator/path-iterator.el (path-iter-all-files): New.
---
.../path-iterator-resources/alice-1/foo-file1.text | 1 +
.../bob-1/bob-2/foo-file2.text | 1 +
.../bob-1/bob-3/foo-file3.text | 1 +
packages/path-iterator/path-iterator-test.el | 19 ++++++++++++++++++-
packages/path-iterator/path-iterator.el | 17 +++++++++++++++++
5 files changed, 38 insertions(+), 1 deletion(-)
diff --git
a/packages/path-iterator/path-iterator-resources/alice-1/foo-file1.text
b/packages/path-iterator/path-iterator-resources/alice-1/foo-file1.text
new file mode 100644
index 0000000..d83a9f4
--- /dev/null
+++ b/packages/path-iterator/path-iterator-resources/alice-1/foo-file1.text
@@ -0,0 +1 @@
+alice-1/foo-file1.text
diff --git
a/packages/path-iterator/path-iterator-resources/bob-1/bob-2/foo-file2.text
b/packages/path-iterator/path-iterator-resources/bob-1/bob-2/foo-file2.text
new file mode 100644
index 0000000..6bd9bdb
--- /dev/null
+++ b/packages/path-iterator/path-iterator-resources/bob-1/bob-2/foo-file2.text
@@ -0,0 +1 @@
+bob-1/foo-file2.text
diff --git
a/packages/path-iterator/path-iterator-resources/bob-1/bob-3/foo-file3.text
b/packages/path-iterator/path-iterator-resources/bob-1/bob-3/foo-file3.text
new file mode 100644
index 0000000..2a3b1e9
--- /dev/null
+++ b/packages/path-iterator/path-iterator-resources/bob-1/bob-3/foo-file3.text
@@ -0,0 +1 @@
+bob-2/foo-file5.text
diff --git a/packages/path-iterator/path-iterator-test.el
b/packages/path-iterator/path-iterator-test.el
index 09c01da..780e744 100644
--- a/packages/path-iterator/path-iterator-test.el
+++ b/packages/path-iterator/path-iterator-test.el
@@ -158,7 +158,7 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
(let ((default-directory path-iter-root-dir))
(should
(equal
- (path-iter-to-truename
+ (path-iter--to-truename
(list
nil
(concat path-iter-root-dir "/alice-1")))
@@ -168,5 +168,22 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
)))
+(ert-deftest path-iter-all-files ()
+ (let ((iter
+ (make-path-iterator
+ :user-path-non-recursive nil
+ :user-path-recursive (list path-iter-root-dir))))
+
+ (should
+ (equal
+ (path-iter-all-files iter)
+ (list
+ (concat path-iter-root-dir "/bob-1/bob-3/foo-file3.text")
+ (concat path-iter-root-dir "/bob-1/bob-2/foo-file2.text")
+ (concat path-iter-root-dir "/alice-1/foo-file1.text")
+ (concat path-iter-root-dir "/file-0.text")
+ )))
+ ))
+
(provide 'path-iterator-test)
;;; path-iterator.el ends here
diff --git a/packages/path-iterator/path-iterator.el
b/packages/path-iterator/path-iterator.el
index ca208e4..1c57ce3 100644
--- a/packages/path-iterator/path-iterator.el
+++ b/packages/path-iterator/path-iterator.el
@@ -285,5 +285,22 @@ Return a list of absolute filenames or nil if none found."
(file-name-all-completions filename dir)))
result))
+(defun path-iter-all-files (iter)
+ "Return all filenames in ITER (a `path-iterator' object."
+ (let (result)
+ (path-iter-restart iter)
+
+ (while (not (path-iter-done iter))
+ (let ((dir (path-iter-next iter)))
+ (mapc
+ (lambda (absfile)
+ (when (and (not (string-equal "." (substring absfile -1)))
+ (not (string-equal ".." (substring absfile -2)))
+ (not (file-directory-p absfile)))
+ (push absfile result)))
+ (directory-files dir t))
+ ))
+ result))
+
(provide 'path-iterator)
;;; path-iterator.el ends here.
- [elpa] master updated (53bcfc9 -> 4a83f36), Stephen Leake, 2019/02/01
- [elpa] master 3b3ca82 3/5: Fix bugs, add tests in uniquify-files, Stephen Leake, 2019/02/01
- [elpa] master 02764f9 4/5: Improve uniquify-files-test.el, improve uniquify-files to handle new tests, Stephen Leake, 2019/02/01
- [elpa] master a323e93 2/5: In uniquify-files, handle list tables, refactor code, update tests, Stephen Leake, 2019/02/01
- [elpa] master 16390ac 1/5: In path-iterator, add new function and test,
Stephen Leake <=
- [elpa] master 4a83f36 5/5: Merge commit '53bcfc9e49f6306ac3e911a9de3d4a2a74c70f95', Stephen Leake, 2019/02/01