developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 12 years ago

Closed 12 years ago

#570 closed bug (fixed)

jZipCreator : empty dirs are not included in the archive

Reported by: Julien Owned by: Julien
Priority: normal Milestone: Jelix 1.0.4
Component: jelix:utils Version: 1.0.3
Severity: minor Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

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 (2)

570-jZipCreator-empty-dirs-support.diff (4.3 KB) - added by Julien 12 years ago.
patch with empty dirs support
570-jZipCreator-empty-dirs-support.2.diff (7.2 KB) - added by Julien 12 years ago.
updated, improved, factorized patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 12 years ago by Julien

  • Owner set to Julien
  • Status changed from new to assigned

comment:2 Changed 12 years ago by laurentj

  • Milestone set to Jelix 1.0.4
  • Severity changed from normal to minor

Changed 12 years ago by Julien

patch with empty dirs support

comment:3 Changed 12 years ago 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.

comment:4 Changed 12 years ago 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 :-)

comment:5 Changed 12 years ago by Julien

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

Changed 12 years ago by Julien

updated, improved, factorized patch

comment:6 Changed 12 years ago 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 ?

comment:7 Changed 12 years ago by Julien

  • review changed from review+ to review?

comment:8 Changed 12 years ago by laurentj

  • review changed from review? to review+

ok

comment:9 Changed 12 years ago by Julien

  • Resolution set to fixed
  • Status changed from assigned to closed

commited

Note: See TracTickets for help on using tickets.