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 » GZDecompress bug
Re: GZDecompress bug [message #22687 is a reply to message #22685] Wed, 05 August 2009 08:49 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14258
Registered: November 2005
Ultimate Member
int GZDecompress(Stream& out, Stream& in, int size, Gate2<int, int> progress)


Here the 'size' parameter is a number of bytes to be read from in.

The size of .gz is 75 bytes, but you put there 48.

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	FileOut out("u:/gztest/output.bin");
	FileIn in;

	if (!in.Open("u:/gztest/MedicalEnRu_abrv.idx.gz"))
		return;
	
	Buffer<char> index_data;
	MemStream index_stream;
	const int idx_file_size = 48;

	// Preallocate memory and create a memory stream ...
	index_data.Alloc(idx_file_size);
	index_stream.Create(~index_data, idx_file_size);

	GZDecompress(index_stream, in, in.GetLeft());
	index_stream.Seek(0);
			
	CopyStream(out, index_stream);
}


This works.

BTW, why MemStream? You can use 'out' as output directly without CopyStream.

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Environment variables code page
Next Topic: ConvertInt > templatable Convert<T>
Goto Forum:
  


Current Time: Wed May 14 19:47:29 CEST 2025

Total time taken to generate the page: 0.03431 seconds