Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
mirek is currently offline  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).
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Folder for configuration file
Next Topic: DEPRECATED flag
Goto Forum:
  


Current Time: Tue May 14 05:56:40 CEST 2024

Total time taken to generate the page: 0.02523 seconds