aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/main.scm2
-rw-r--r--src/parse.scm22
2 files changed, 22 insertions, 2 deletions
diff --git a/src/main.scm b/src/main.scm
index efc4e897..408b9de0 100755
--- a/src/main.scm
+++ b/src/main.scm
@@ -15,7 +15,7 @@
(format (current-error-port) "Parsing ~s~%" (cadr args))
- (let ((cal (read-vcalendar (cadr args))))
+ (let ((cal (read-tree (cadr args))))
(format #t "cal = ~a~%" cal)
(format (current-error-port) "~a events~%" (length cal)))
diff --git a/src/parse.scm b/src/parse.scm
index a6f3bed1..b11240df 100644
--- a/src/parse.scm
+++ b/src/parse.scm
@@ -4,7 +4,7 @@
:use-module (rnrs bytevectors)
:use-module (srfi srfi-9)
:use-module ((ice-9 textual-ports) :select (unget-char))
- :use-module ((ice-9 ftw) :select (scandir)))
+ :use-module ((ice-9 ftw) :select (scandir ftw)))
@@ -271,3 +271,23 @@ row ~a column ~a ctx = ~a
(string= "ics" (string-take-right s 3))))))]
[(block-special char-special fifo socket unknown symlink)
=> (lambda (t) (error "Can't parse file of type " t))]))
+
+
+(define-public (read-tree path)
+ (define list '())
+ (ftw path
+ (lambda (filename statinfo flag)
+ (case flag
+ [(regular)
+ (case (stat:type statinfo)
+ [(regular)
+ (when (and (not (string= "." (string-take filename 1)))
+ (string= "ics" (string-take-right filename 3)))
+ (set! list (cons filename list)))
+ #t]
+ [else #t])]
+ [(directory) #t]
+ [else #f])))
+ ((@ (ice-9 threads) n-par-map) 12
+ (lambda (fname) (call-with-input-file fname parse-calendar))
+ list))