Megatest

Check-in [c8e58c2956]
Login
Overview
Comment:Improved multi-glob
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65
Files: files | file ages | folders
SHA1: c8e58c2956d3ae8924cea61bbfc83fd3f0914b6f
User & Date: mrwellan on 2019-11-21 09:25:02
Other Links: branch diff | manifest | tags
Context
2019-11-21
18:38
Added alt version of multi-glob from Robert. check-in: 80a94ea109 user: matt tags: v1.65
09:25
Improved multi-glob check-in: c8e58c2956 user: mrwellan tags: v1.65
03:22
Added beginnings of multi-level glob check-in: e22603e687 user: matt tags: v1.65
Changes

Modified multi-glob.scm from [86fb1e2447] to [1e40166643].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21
22
(define (multi-glob pathspec)
  (let* ((path-parts (string-split pathspec "/" #t)))
    (if (null? path-parts)
	'()
	(let loop ((parts  (cdr path-parts))
		   (result (let ((p (car path-parts)))
			     (if (string=? p "")
				 '("/")
				 (glob (car path-parts))))))
	  (if (null? parts)
	      result
	      (let* ((part (car parts))
		     (rem  (cdr parts)))
		(loop rem
		      (apply append
			     (map (lambda (curr)
				    (let ((new (string-append curr "/" part)))
				      (if (and (directory? curr)
					       (file-read-access? curr))
					  (glob new)

					  '())))
				  result)))))))))

|














|
|
|
|
>
|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(define (multi-glob pathspec)
  (let* ((path-parts (intersperse (string-split pathspec "/" #t) "/")))
    (if (null? path-parts)
	'()
	(let loop ((parts  (cdr path-parts))
		   (result (let ((p (car path-parts)))
			     (if (string=? p "")
				 '("/")
				 (glob (car path-parts))))))
	  (if (null? parts)
	      result
	      (let* ((part (car parts))
		     (rem  (cdr parts)))
		(loop rem
		      (apply append
			     (map (lambda (curr)
				    (let ((new (string-append curr part)))
				      (cond
				       ((and (directory? curr)(file-read-access? curr))
					(glob new))
				       ((member part '("." ".." "/")) new)
				       (else '()))))
				  result)))))))))