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
;;; Copyright (C) 2016-2017 by nee <nee-git@hidamari.blue>
;;; this is a part of gutter and licensed under to AGPL3.0
;;; see https://gnu.org/l/agpl-3.0
(define-module (download)
#:export (with-download
download
test-download))
(define (success? return-code)
(= 0 return-code))
(define (download download-path url)
(if (not (file-exists? download-path))
(and (success? (system* "wget" "-O" download-path url))
download-path)
download-path))
(define (test-download download-path url)
"useful for testcases"
(copy-file (string-append "test/download/" (basename url))
download-path)
download-path)
(define (with-download download-path url callback)
(download download-path url)
(call-with-input-file download-path callback))