From 26872de184e4aa2ae92bae645782089e9656115d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 11 May 2010 11:41:59 +0100 Subject: Added an option to remove the preceding trail of empty folders when creating a Zip archive. --- user_guide/changelog.html | 1 + user_guide/libraries/zip.html | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'user_guide') diff --git a/user_guide/changelog.html b/user_guide/changelog.html index ae63b1f5f..08c98157b 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -95,6 +95,7 @@ Hg Tag:

  • Added a download() method to the FTP library
  • Changed do_xss_clean() to return FALSE if the uploaded file fails XSS checks.
  • Added stripslashes() and trim()ing of double quotes from $_FILES type value to standardize input in Upload library.
  • +
  • Added a second parameter (boolean) to $this->zip->read_dir('/path/to/directory', FALSE) to remove the preceding trail of empty folders when creating a Zip archive. This example would contain a zip with "directory" and all of its contents.
  • Database diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html index 44603f2bc..844023b9e 100644 --- a/user_guide/libraries/zip.html +++ b/user_guide/libraries/zip.html @@ -177,7 +177,7 @@ $this->zip->download('my_backup.zip');

    $this->zip->read_dir()

    -

    Permits you to compress a folder (and its contents) that already exists somewhere on your server. Supply a file path to the +

    Permits you to compress a folder (and its contents) that already exists somewhere on your server. Supply a file path to the directory and the zip class will recursively read it and recreate it as a Zip archive. All files contained within the supplied path will be encoded, as will any sub-folders contained within it. Example:

    @@ -189,6 +189,16 @@ $this->zip->read_dir($path); $this->zip->download('my_backup.zip'); +

    By default the Zip archive will place all directories listed in the first parameter inside the zip. If you only want the end folder to be in the zip +you can pass FALSE (boolean) in the second parameter. Example:

    + + +$path = '/path/to/your/directory/';

    +$this->zip->read_dir($path, FALSE); +
    + +

    This will create a ZIP with the folder "directory" inside, then all sub-folders stored correctly inside that.

    + -- cgit v1.2.3-24-g4f1b