X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Fwget_src%2Fmain.c;h=d068053449e737d9fdda9eb5710f8a9c3f28a6ce;hb=2238e69eea50d2274553926f3f294822c1972ff0;hp=ee324577f9f58fc7cd7ac38068c7cfd6cc757af8;hpb=3bcb134d0523071a59375fdda3ab3e9ef8076dfb;p=tpg%2Facess2.git diff --git a/Usermode/Applications/wget_src/main.c b/Usermode/Applications/wget_src/main.c index ee324577..d0680534 100644 --- a/Usermode/Applications/wget_src/main.c +++ b/Usermode/Applications/wget_src/main.c @@ -197,7 +197,7 @@ void streamToFile(int Socket, const char *OutputFile, int bAppend, size_t bytes_ return ; } - int64_t start_time = _SysTimestamp(); + int64_t start_time = _SysTimestamp()-1; size_t bytes_seen = 0; // Write the remainder of the buffer do @@ -205,19 +205,21 @@ void streamToFile(int Socket, const char *OutputFile, int bAppend, size_t bytes_ write(outfd, inbuf, len); bytes_seen += len; _SysDebug("%i/%i bytes done", bytes_seen, bytes_wanted); - printf("%7i/%7i KiB (%iKiB/s)\r", + printf("%7i/%7i KiB (%ikB/s) \r", bytes_seen/1024, bytes_wanted/1024, bytes_seen/(_SysTimestamp() - start_time) ); fflush(stdout); - len = read(Socket, inbuf, buflen); + if( bytes_seen < bytes_wanted ) + len = read(Socket, inbuf, buflen); } while( bytes_seen < bytes_wanted && len > 0 ); + int64_t stop_time = _SysTimestamp(); close(outfd); - printf("%i KiB done in %is (%i KiB/s)\n", + printf("%i KiB done in %is (%i kB/s)\n", bytes_seen/1024, - (_SysTimestamp() - start_time)/1000, - bytes_seen/(_SysTimestamp() - start_time) + (int)(stop_time - start_time)/1000, + bytes_seen/(stop_time - start_time) ); }