ObjFW  Diff

Differences From Artifact [541aee4c03]:

To Artifact [e84b0f1e4e]:


98
99
100
101
102
103
104
105

106
107

108
109
110
111
112
113
114
98
99
100
101
102
103
104

105
106

107
108
109
110
111
112
113
114







-
+

-
+







	else
		barWidth = 0;
#else
	barWidth = 43;
#endif

	bars = (float)(_resumedFrom + _received) /
	    (_resumedFrom + _length) * barWidth;
	    (float)(_resumedFrom + _length) * barWidth;
	percent = (float)(_resumedFrom + _received) /
	    (_resumedFrom + _length) * 100;
	    (float)(_resumedFrom + _length) * 100;

	[of_stdout writeString: @"\r  ▕"];

	for (i = 0; i < (size_t)bars; i++)
		[of_stdout writeString: @"█"];
	if (bars < barWidth) {
		float remainder = bars - floorf(bars);
135
136
137
138
139
140
141
142

143
144
145
146
147
148
149
135
136
137
138
139
140
141

142
143
144
145
146
147
148
149







-
+







	}

	[of_stdout writeFormat: @"▏ %6.2f%% ", percent];

	if (percent == 100) {
		double timeInterval = -[_startDate timeIntervalSinceNow];

		_BPS = (float)_received / timeInterval;
		_BPS = (float)_received / (float)timeInterval;
		_ETA = timeInterval;
	}

	if (isinf(_ETA))
		[of_stdout writeString: @"--:--:-- "];
	else if (_ETA >= 99 * 3600)
		[of_stdout writeFormat: @"%4.2f d ", _ETA / (24 * 3600)];
177
178
179
180
181
182
183
184


185
186
187
188
189
190
191
177
178
179
180
181
182
183

184
185
186
187
188
189
190
191
192







-
+
+







		    @"\r  %7.2f KiB ",
		    (float)(_resumedFrom + _received) / KIBIBYTE];
	else
		[of_stdout writeFormat:
		    @"\r  %jd bytes ", _resumedFrom + _received];

	if (_stopped)
		_BPS = (float)_received / -[_startDate timeIntervalSinceNow];
		_BPS = (float)_received /
		    -(float)[_startDate timeIntervalSinceNow];

	if (_BPS >= GIBIBYTE)
		[of_stdout writeFormat: @"%7.2f GiB/s", _BPS / GIBIBYTE];
	else if (_BPS >= MEBIBYTE)
		[of_stdout writeFormat: @"%7.2f MiB/s", _BPS / MEBIBYTE];
	else if (_BPS >= KIBIBYTE)
		[of_stdout writeFormat: @"%7.2f KiB/s", _BPS / KIBIBYTE];
200
201
202
203
204
205
206
207

208
209
210
211
212
213
214
201
202
203
204
205
206
207

208
209
210
211
212
213
214
215







-
+







	else
		[self _drawReceived];
}

- (void)calculateBPSAndETA
{
	_BPS = (float)(_received - _lastReceived) /
	    -[_lastReceivedDate timeIntervalSinceNow];
	    -(float)[_lastReceivedDate timeIntervalSinceNow];
	_ETA = (double)(_length - _resumedFrom - _received) / _BPS;

	_lastReceived = _received;
	[_lastReceivedDate release];
	_lastReceivedDate = [[OFDate alloc] init];
}