~nabijaczleweli/voreutils

73c57c05b6d978fff5430073c3ead61d9c78c1cb — наб a month ago 4d1b3a2
Fix extra space in dd progress seconds. Add daysThh:mm:ss readout after a minute
1 files changed, 26 insertions(+), 3 deletions(-)

M cmd/dd.cpp
M cmd/dd.cpp => cmd/dd.cpp +26 -3
@@ 222,16 222,37 @@ static void do_speed_stats(const struct timespec & now, bool final = false) {
	if(human_size(speed, sizeof(speed), average, vore::human_size_t::human_1024, !final, true))
		std::strcat(speed, "i");

	auto big_elapsed = [&] {
		if(elapsed < 60.)
			return;

		double lapse_d;
		std::modf(elapsed, &lapse_d);
		auto lapse = static_cast<std::uint64_t>(lapse_d);

		std::fputs(" (", stderr);
		bool above{};
		if(lapse >= 24 * 60 * 60)
			std::fprintf(stderr, "%" PRIu64 "T", lapse / (24 * 60 * 60)), above = true;
		if(lapse >= 60 * 60)
			std::fprintf(stderr, above ? "%02" PRIu64 ":" : "%2" PRIu64 ":", (lapse / (60 * 60)) % 24), above = true;
		if(lapse >= 60)
			std::fprintf(stderr, above ? "%02" PRIu64 ":" : "%2" PRIu64 ":", (lapse / 60) % 60);
		std::fprintf(stderr, "%02" PRIu64 ")", lapse % 60);  // always >=60 as precond
	};

	if(!final) {
		std::fprintf(stderr, "\r%" PRIu64 "B ", copied_data);
		if(copied_data >= 1000)
			std::fprintf(stderr, "(%sB, %sB) ", human, si___);
		std::fprintf(stderr, "/ % 3.0fs; %sB/s", elapsed, speed);
		std::fprintf(stderr, "/ %3.fs", elapsed);
		big_elapsed();
		std::fprintf(stderr, "; %sB/s", speed);
		if(last_copied_data) {
			char momentary_speed[12 + 1];
			if(human_size(momentary_speed, sizeof(momentary_speed), momentary, vore::human_size_t::human_1024, true, true))
				strcat(momentary_speed, "i");
			std::fprintf(stderr, " (%sB/%.0fs)", momentary_speed, since_last);
			std::fprintf(stderr, " (%sB/%.fs)", momentary_speed, since_last);
		}
		vore::fflush(stderr);
		partial_speedstat_line = true;


@@ 241,7 262,9 @@ static void do_speed_stats(const struct timespec & now, bool final = false) {
		std::fprintf(stderr, "%" PRIu64 "B ", copied_data);
		if(copied_data >= 1000)
			std::fprintf(stderr, "(%sB, %sB)", human, si___);
		std::fprintf(stderr, " / %gs; %sB/s\n", elapsed, speed);
		std::fprintf(stderr, " / %gs", elapsed);
		big_elapsed();
		std::fprintf(stderr, "; %sB/s\n", speed);
	}
}