Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/param.h>
- #include <stdio.h>
- #include <fetch.h>
- int main(int argc, char** argv)
- {
- FILE* local = NULL;
- FILE* remote = NULL;
- struct url_stat us;
- char buf[10240];
- size_t n = 0;
- size_t sum = 0;
- local = fopen("foo.bin", "w+");
- remote = fetchXGetURL(argv[1], &us, "");
- while (true) {
- n = fread(buf, 1, sizeof(buf), remote);
- if (n == 0) {
- break;
- }
- sum += fwrite(buf, 1, n, local);
- printf("got: %d/%d, %d%%\r", sum, us.size, (int)((float)sum/us.size*100));
- fflush(stdout);
- }
- fclose(remote);
- fclose(local);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement