CI Zip Library |
[eluser]John Ashwin[/eluser]
Hiya, Well, this is a problem I faced a few days back, and this is the simple fix that i used. It is actually a mod of this extension for a different zip class: tutorial-create-a-zip-file-from-folders-on-the-fly It was a frustrating problem, and I hope this will help someone else. When zipping up a folder outside my root like eg: Code: $path = '/path/to/your/directory/'; The resulting zip file had the same structure eg: my_backup.zip/path/to/your/directory/ This simple extension of the Zip library allows me to get files from a deep folder and rename the structure in the Zip. Usage: Code: $path = '/path/to/your/directory/'; mybackup.zip/source-code/(contents and inner of $path) Code: // MY_Zip.php Do post your suggestions or if there are other better solutions. Cheers, John Ashwin
[eluser]louis w[/eluser]
Thanks for the post. I REALLY think Ellis Labs needs to roll something like this into the zip library. Keeping the full server directory path is quite annoying - especially with client facing sites. Also, because your not doing anything in the constructor, you don't need to have it in your extended class. This can be removed: Code: function MY_Zip()
[eluser]louis w[/eluser]
After testing this out, I didn't like how the data inside the folder I was trying to add still needed to be inside a directory in the archive. I checked out the CI read_dir call, a couple small changes you can call read_dir to create an archive containing all the files without any directories. Even works with nested folders. Code: class MY_Zip extends CI_Zip {
[eluser]John Ashwin[/eluser]
Thanks man.. I've included your function into the extension. It will come in very useful for for an upcoming project. There's another mod as well. Empty timestamps were causing notepad++ and sourceDiff to crash on me. lol.. It seems winrar and stuffit don't handle missing timestamps very well, during extraction. This is the excerpt. The full code is in the attachment. Code: /**
|
Welcome Guest, Not a member yet? Register Sign In |