Home » U++ Library support » U++ Core » Upp::CopyStream reports wrong size.
Re: Upp::CopyStream reports wrong size. [message #50214 is a reply to message #50201] |
Mon, 27 August 2018 18:08 |
|
mirek
Messages: 13980 Registered: November 2005
|
Ultimate Member |
|
|
Good point.
I think moving Put after progress might be a bit better:
int64 CopyStream(Stream& dest, Stream& src, int64 count, Gate<int64, int64> progress)
{
int block = (int)min<int64>(count, 32768);
Buffer<byte> temp(block);
int loaded;
int64 done = 0;
int64 total = count;
while(count > 0 && (loaded = src.Get(~temp, (int)min<int64>(count, block))) > 0) {
count -= loaded;
done += loaded;
if(progress(done, total))
return -1;
dest.Put(~temp, loaded);
}
return done;
}
what do you think? (it will reach 100% sooner, but in situation where you close progress immediately after finish it will be at 100% for some time).
|
|
|
Goto Forum:
Current Time: Tue May 14 05:56:40 CEST 2024
Total time taken to generate the page: 0.02523 seconds
|