show progress of downloading

This commit is contained in:
SANO Masatoshi 2014-11-02 01:01:54 +09:00
parent d1ee0b18fa
commit 45069a1753
2 changed files with 15 additions and 1 deletions

View file

@ -101,7 +101,7 @@ int download(struct install_options* param)
return 0;
/* fail */
}else{
printf("download done:%s\n",url);
printf("\ndone\n");
}
}
s(impl_archive),s(url);

View file

@ -2,9 +2,23 @@
#include <stdlib.h>
#include <curl/curl.h>
static int count=0;
static int block=10240;
static int fold=90;
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
int written = fwrite(ptr, size, nmemb, (FILE *)stream);
int current = count/block;
int dots;
int i;
count+=written;
for(i=current;i<count/block;++i){
printf(".");
fflush(stdout);
if(i%fold==0)
printf("\n");
}
return written;
}