mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-27 13:14:26 -04:00
[ui] add experimental optional display of transfer speed and time remaining
* You can use <Alt> to switch modes during an operation that supports it (e.g. Checksum computation, DD image writing or zeroing, save to VHD, download, etc. * IMPORTANT: This is *NOT* available for all operations. Especially, if you were hoping to get transfer speed or ETA during ISO or WIM extraction, you *WILL* be disappointed. * Also harmonize the code in checksum.c
This commit is contained in:
parent
94e2015edf
commit
af95de8198
16 changed files with 525 additions and 430 deletions
23
src/stdio.c
23
src/stdio.c
|
@ -695,6 +695,29 @@ char* TimestampToHumanReadable(uint64_t ts)
|
|||
return str;
|
||||
}
|
||||
|
||||
// TODO: Add granularity
|
||||
char* RateToHumanReadable(uint64_t transferred, uint64_t total)
|
||||
{
|
||||
const uint64_t refresh_rate = 1000;
|
||||
static uint64_t start_time, last_refresh = 0;
|
||||
uint64_t current_time, rate;
|
||||
if (total == 0) {
|
||||
// init
|
||||
start_time = GetTickCount64();
|
||||
last_refresh = start_time;
|
||||
} else {
|
||||
current_time = GetTickCount64();
|
||||
if (current_time <= start_time)
|
||||
return NULL;
|
||||
rate = (transferred * 1000) / (current_time - start_time);
|
||||
if (current_time > last_refresh + refresh_rate) {
|
||||
last_refresh = current_time;
|
||||
uprintf("%s/s", SizeToHumanReadable(rate, FALSE, FALSE));
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Convert custom error code to messages
|
||||
const char* _StrError(DWORD error_code)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue