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.
Upp::CopyStream reports wrong size. [message #50201] Sat, 25 August 2018 21:39 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello,

While I've tried to use the CopyStream variant in SSH/SFtp, I found out that it is not reporting the final size.

This:
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) {
		if(progress(done, total)) // <-- This doesn't report the final size.
			return -1;        //
		dest.Put(~temp, loaded); 
		count -= loaded;
		done += loaded;
	}
	return done;
}


Should be (?):

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) {
	        dest.Put(~temp, loaded);
		count -= loaded;
		done += loaded;
	        if(progress(done, total)) // <-- This works.
			return -1;
	
	}
	return done;
}


Best regards,
Oblivion


 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Folder for configuration file
Next Topic: DEPRECATED flag
Goto Forum:
  


Current Time: Sun Apr 28 20:16:58 CEST 2024

Total time taken to generate the page: 0.05047 seconds