diff options
author | John Benediktsson <mrjbq7@gmail.com> | 2024-04-15 11:37:48 -0700 |
---|---|---|
committer | John Benediktsson <mrjbq7@gmail.com> | 2024-04-15 11:37:48 -0700 |
commit | 9388dfb951833aae22dcf7133f41fe33cc066dcd (patch) | |
tree | 5a70e4793be07f49fd30159e0b050ca17d339c0b | |
parent | 7ed9ce57502d03a5ad582347688b0e977eea37d2 (diff) |
curl: add a curl-download
-rw-r--r-- | extra/curl/curl.factor | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/extra/curl/curl.factor b/extra/curl/curl.factor index c8ae39ffcf..03d438167b 100644 --- a/extra/curl/curl.factor +++ b/extra/curl/curl.factor @@ -1,10 +1,9 @@ ! Copyright (C) 2014 John Benediktsson ! See https://factorcode.org/license.txt for BSD license -USING: alien alien.c-types alien.data alien.destructors -alien.syntax command-line curl.ffi destructors io -io.encodings.string io.encodings.utf8 io.streams.c kernel math -namespaces present sequences ; +USING: alien.destructors command-line curl.ffi destructors +http.download io.backend io.streams.c kernel namespaces present +sequences ; IN: curl @@ -27,7 +26,7 @@ DESTRUCTOR: fclose CURLOPT_URL swap present curl-set-opt ; : curl-set-file ( CURL path -- ) - CURLOPT_FILE swap "wb" fopen &fclose curl-set-opt ; + CURLOPT_FILE swap normalize-path "wb" fopen &fclose curl-set-opt ; : curl-perform ( CURL -- ) curl_easy_perform check-code ; @@ -42,6 +41,9 @@ PRIVATE> [ curl-perform ] tri ] with-destructors ; +: curl-download ( url -- path ) + dup download-name [ curl-download-as ] keep ; + : curl-main ( -- ) command-line get [ curl-init |