aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/data-stores/file.scm
blob: 5467622471f304622c6cf4b27efb4a78b30e1e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(define-module (vcomponent data-stores file)
  :use-module (oop goops)
  :use-module ((srfi srfi-88) :select ())
  :use-module ((calp) :select (prodid))
  :use-module (vcomponent data-stores common)
  :use-module ((vcomponent formats ical) :select (serialize deserialize))
  )

(define-class <file-data-store> (<calendar-data-store>)
  (path getter: path
        init-keyword: path:))

(define (make-file-store path)
  (make <file-store> path: path))

(define-method (get-all (this <file-data-store>))
  ;; X-WR-CALNAME ⇒ NAME
  ;; X-WR-CALDESC
  (call-with-input-file (path this)
    deserialize))

(define-method (get-by-uid (this <file-data-store>) (uid <string>))
  #f
  )

(define-method (queue-write (this <file-data-store>) vcomponent)
  )

(define-method (flush (this <file-data-store>))
  (with-atomic-output-to-file (path this)
    (lambda () (serialize (data this) (current-output-port))))
  )