Ticket #570 (closed bug: fixed)

Opened 3 months ago

Last modified 2 months ago

jZipCreator : empty dirs are not included in the archive

Reported by: Julien Assigned to: Julien
Priority: normal Milestone: Jelix 1.0.4
Component: jelix:utils Version: 1.0.3
Severity: minor Keywords:
Cc: Php version:
Review: review+ Hosting Provider:
Documentation needed: 0 Blocking:

Description

When we add directories in an archive using jZipCreator, empty dirs (ie without files inside) are not added.

I will add a new public method called addEmptyDir($name) wich will allow to add an empty dir.

The existing addDir() method will also be fixed (will call addEmptyDir() when needed) to include empty dirs.

Attachments

570-jZipCreator-empty-dirs-support.diff (4.3 kB) - added by Julien on 05/05/08 21:10:17.
patch with empty dirs support
570-jZipCreator-empty-dirs-support.2.diff (7.2 kB) - added by Julien on 05/22/08 15:43:37.
updated, improved, factorized patch

Change History

05/04/08 19:07:04 changed by Julien

  • owner set to Julien.
  • status changed from new to assigned.

05/04/08 23:34:39 changed by laurentj

  • severity changed from normal to minor.
  • milestone set to Jelix 1.0.4.

05/05/08 21:10:17 changed by Julien

  • attachment 570-jZipCreator-empty-dirs-support.diff added.

patch with empty dirs support

05/05/08 21:16:14 changed by Julien

  • review set to review?.

There's a new public method called addEmptyDir(). It uses quite the same code used for file addition, but external attributes are set to 16 instead of 32.

I found this value from some threads about zip files usage in python.

It seems that we can also use 48 instead of 16, but I don't see any difference.

05/20/08 18:51:34 changed by laurentj

  • review changed from review? to review+.

Ok, it seems ok to me, although you could do factorization between addContentFile and addEmptyDir, since most of their line codes are same.

Don't forget to update CREDITS files.

Apply your patch on the 1.0.x branch and on the trunk.

Thanks for this patch :-)

05/22/08 14:23:01 changed by Julien

Ok I'll try refactoring the code before applying the patch.

05/22/08 15:43:37 changed by Julien

  • attachment 570-jZipCreator-empty-dirs-support.2.diff added.

updated, improved, factorized patch

05/22/08 15:47:54 changed by Julien

I improved the patch. Works like the old one, but the code is cleaner and there are some improvements inside.

Also fixed a bug when adding emptydirs, dirs (recursive) and virtual files at the same time.

working action code :

function zip(){
    $rep = $this->getResponse('zip');
    $rep->zipFilename = 'myCrazyPackage.zip';
    $rep->content->addContentFile('dynamic.txt', 'contenu généré comme on veut');
    $rep->content->addDir(dirname(__FILE__).'/../','',true);
    $rep->content->addEmptyDir('tata');
    return $rep;
}

Laurent, Ok for the commit, or would you like to test it again ?

05/23/08 00:07:19 changed by Julien

  • review changed from review+ to review?.

05/28/08 11:16:04 changed by laurentj

  • review changed from review? to review+.

ok

05/28/08 13:27:09 changed by Julien

  • status changed from assigned to closed.
  • resolution set to fixed.

commited

Download in other formats: Comma-delimited Text Tab-delimited Text RSS Feed