aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-11-02 20:08:24 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-11-02 20:08:24 +0100
commita7af12880e92d382653bb4231a05fbf4da3a804a (patch)
treecfd5f15c3f9c352fb969599250fb9eb1645bff73
parentGeneral improvements. (diff)
downloadcalp-a7af12880e92d382653bb4231a05fbf4da3a804a.tar.gz
calp-a7af12880e92d382653bb4231a05fbf4da3a804a.tar.xz
Add slightly silly parse-tree.
-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))