zlib iPhone - files get crap in beginning -


Some .tgz-files have been found in my bundle that I want to uncompress the file and write I got the job - The kind of problem is that the written file gets 512 bytes of crap data in front of it, but in addition, the file has been successfully uncompressed.

I do not want to rubbish. If it is always 512 bytes, then writing is easy to write to others, but is it always so? Something is risky to do that if no one knows why these bytes are in the first place.

  gzFile f = gzopen ([[NSBundle mainBundle] pathForResource: Type the file type: @ "TGG"] CStringUsingEncoding: NSASCIIStringEncoding], [@ "RB" cStringUsingEncoding: NSASCIIStringEncoding]); Unsigned full length = 1024 * 1024; Zero * buffer = maul (length); NSMutableData * Data = [NSMutableData new]; Whereas (true) {int read = gzread (f, buffer, length); If (Read & gt; 0) {[Data EditedBits: Buffer Length: Reading]; } And if (read == 0) break; Else if (read == -1) {throwing with NSE exception exception: @ "Decompression failed" reason: @ "read = 1" user information: zero]; } And {throw [NSE expansion exception: with name: @ "Zlib from unexpected condition" reason: @ "read  

My guess is that after the "junk" decompression at the start of the file, actually the TAR file header (I initially see a file name).

More signs for 512 byte size.

gzip can compress only one file if you are trying to insert only one file, then you do not need to avoid it first.

If you are trying to process multiple files and as a collection, then you have to use TAR and after damprosizing them files.

Just one guess.

Chris.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -