Skip to content
Matthias Görges edited this page Mar 13, 2015 · 1 revision

table->cdb stores table as (optionally encrypted) cdb file.

Parameter Description
t Table to be stored
cdbfile Name of cdb database file to be created
key Optional: u8vector encryption key to be used (minimum length 24)

Example

Example 1: Load a database table from an (optionally encrypted) file.

(define (dbload file key)
  (let ((filepath (string-append (system-directory) (system-pathseparator) file)))
    (if (file-exists? filepath)
      (let ((res1 (cdb->table filepath key)))
        (if (table? res1) 
          res1
          (let ((res2 (with-exception-catcher 
            (lambda (e) (log-error "dbload failed on " filepath) #f) 
            (lambda () (list->table (with-input-from-file filepath (lambda () (read))))))))
              (if (table? res2) (table->cdb res2 filepath key))
              res2
            )
        )
      )
      (begin (log-error "dbload: file not found: " filepath) (make-table)))
  ))
Clone this wiki locally