UrlDownloadToFile() equivalent for linux?
-
Hey, Iam looking for a function i could use that is just as easy to use as UrlDownloadToFile() on windows. C or C++ doesnt matter. Thanks.
-
It may not be as easy to use but on the CURL website there's a simple HTTP[^] client in about 6 lines. Open a file to write to and use CURLOPT_WRITEDATA and snip snip, bob's your Aunty:
#include <stdio.h>
#include <curl/curl.h>int main(void)
{
CURL *curl = curl_easy_init();
FILE *output_to = fopen( "output.txt", "w" );if( curl && output_to )
{
curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se" );
curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_to );
curl_easy_perform(curl);
}if( curl ) curl_easy_cleanup(curl);
if( output_to ) fclose( output_to );
}Bundle that lot up in a function and you're done... Cheers, Ash PS: There's no error reporting if the transfer goes pear shaped PPS: I haven't programmed in C in years and not having cURL handy on my home computer I haven't checked the code compiles and runs but it's not far off
-
Hey, Iam looking for a function i could use that is just as easy to use as UrlDownloadToFile() on windows. C or C++ doesnt matter. Thanks.
Search for a C++ library offering a HTTP client[^], see if it helps.