diff options
author | Piotr Szarmanski | 2023-02-07 16:56:30 +0100 |
---|---|---|
committer | Piotr Szarmanski | 2023-02-07 16:56:30 +0100 |
commit | d9f52ce9f2e5b81443bdac6ae4f3855330bb43a5 (patch) | |
tree | 495cc3c1b7e376d178899566373df60513af1cd7 /examples/file/eris-file.lisp | |
parent | 1c7d53e105fdbd61dd14f526d94bfe87f59e2a20 (diff) |
Remove examples/*.
Diffstat (limited to 'examples/file/eris-file.lisp')
-rw-r--r-- | examples/file/eris-file.lisp | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/examples/file/eris-file.lisp b/examples/file/eris-file.lisp deleted file mode 100644 index fdc53ef..0000000 --- a/examples/file/eris-file.lisp +++ /dev/null @@ -1,30 +0,0 @@ -(in-package :eris-file) -(defvar *eris-directory* "/tmp/") - -(defun output-to-file (block reference) - (let* ((base32 (eris:bytes-to-base32-unpadded reference)) - (file (concatenate 'string *eris-directory* base32))) - (unless (probe-file file) - (alexandria:write-byte-vector-into-file block file)))) - -(defun input-from-file (reference) - (let* ((base32 (eris:bytes-to-base32-unpadded reference)) - (file (concatenate 'string *eris-directory* base32))) - (if (probe-file file) - (alexandria:read-file-into-byte-vector file) - nil))) - -(defun encode-file (input-file &optional (output-directory *eris-directory*)) - (let ((*eris-directory* output-directory)) - (with-open-file (file input-file :direction :input :element-type '(unsigned-byte 8)) - (eris:read-capability-to-urn - (eris:eris-encode file - (if (< (file-length file) (* 1024 16)) 1024 eris:32kib) - #'output-to-file - :hash-output nil))))) - -(defun decode-file (urn output-file &optional (output-directory *eris-directory*)) - (let ((*eris-directory* output-directory)) - (with-open-file (file output-file :direction :output :element-type '(unsigned-byte 8)) - (alexandria:copy-stream (eris:eris-decode (eris:urn-to-read-capability urn) #'input-from-file) - file)))) |