Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

How to close a ZipBlockReader ?

Moderators: larsivi kris

Posted: 05/02/08 08:49:05 Modified: 05/02/08 11:35:21

Hi all,

Here is a code that simply decompress a zip's files in a folder. But it give me some exception :

import tango.stdc.Stdio;
import tango.text.Util;

char[][] decompressFile(char[] pathZip,char[] destFolder)
	char[][] pathDests;
	Stdout("Decomp of : ")(pathZip).newline;
	char[] destFile;
	auto zipReader = new ZipBlockReader( pathZip );
		destFile = destFolder ~ "\\" ~   replace(  , '/' , '_' );	// Pas de dossier, mais uniquement des fichiers pour ne pas avoir à recréer les dossiers

		auto outfile=new FileConduit(
			, FileConduit.WriteCreate);

		// Ecrit dans le fichier de destination
		InputStream inStream =;
		outfile.output.copy( inStream );

		// insére à la liste des fichiers à retourner
		pathDests ~= destFile;

	//delete zipReader;

	Stdout("Here, the zip file must be close.\nPress a key...").newline;
	return pathDests;

void main(char[][] args)

But it give me the exception :

object.Exception: Access Violation
object.Exception: Access Violation

I'm on :

  Windows Vista
  DMD v1.025
  Tango from SVN (revision 3478)

Thanks you in advance for your help. TSalm

Author Message

Posted: 05/02/08 12:04:50

Vista is innocent :

After trying with another zip file, the code decompresse this other file with no problem. I'm testing it with the latest tango bundle (with dmd v1.029) on Vista and the problem is the same.

And the same test with those 2 zip files, compiling the code on Windows XP with the latest tango bundle (with dmd v1.029) give the same results.

Posted: 05/02/08 17:00:35

Not sure if this is part of the problem or not, but I suspect replace() modifies the provided array. Try a .dup on the Also, it looks like you're not closing the input files as you go, but that shouldn't cause this issue. Can you run it through a debugger to see where (in the code) it fails?

Posted: 05/02/08 20:48:31

I add .dup like this, but the problem persist :

destFile = destFolder ~ "\\" ~   replace(  , '/' , '_' );

Finally, it seems to be a bug : I find a way to reproduct the problem : - create or rename a file to the name: "" ( 15 characters ) - zip it - use my code below to decompress the zip and it must give the fatal error

This exception bare one's teeth in the module in the class "ZipBlockReader?" in the "close" method at the line "delete file_source" :

if( file_source !is null )
         delete file_source;

Posted: 05/03/08 09:22:51

eesh :(

Thanks for tracking it down! Would you mind creating a ticket and assigning it to DRK, please?

Posted: 05/03/08 20:11:29 -- Modified: 05/03/08 20:16:00 by

kris wrote:

eesh :(

Thanks for tracking it down! Would you mind creating a ticket and assigning it to DRK, please?


But not sure about the priority level, so I let the default one... Thanks.