Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

I added an argument in the read_file function to enable users to rename ... #884

Closed
wants to merge 1 commit into from

4 participants

@desduvauchelle

...the files that they are about to zip. I was thinking of this when I was implementing a sort of gmail download where each file names are encoded and then zipped to be downloaded.

@desduvauchelle desduvauchelle I added an argument in the read_file function to enable users to rena…
…me the files that they are about to zip. I was thinking of this when I was implementing a sort of gmail download where each file names are encoded and then zipped to be downloaded.
9d223e5
@philsturgeon philsturgeon commented on the diff
system/libraries/Zip.php
@@ -260,17 +260,20 @@ function read_file($path, $preserve_filepath = FALSE)
if (FALSE !== ($data = file_get_contents($path)))
{
- $name = str_replace("\\", "/", $path);
+ if($name == NULL)

Please can you put a space between the if and the (.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beaucharman

Would be awesome to get this committed

@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 7, 2012
  1. @desduvauchelle

    I added an argument in the read_file function to enable users to rena…

    desduvauchelle authored
    …me the files that they are about to zip. I was thinking of this when I was implementing a sort of gmail download where each file names are encoded and then zipped to be downloaded.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 6 deletions.
  1. +9 −6 system/libraries/Zip.php
View
15 system/libraries/Zip.php
@@ -251,7 +251,7 @@ function _add_data($filepath, $data, $file_mtime, $file_mdate)
* @access public
* @return bool
*/
- function read_file($path, $preserve_filepath = FALSE)
+ function read_file($path, $preserve_filepath = FALSE, $name = NULL) // Added $name
{
if ( ! file_exists($path))
{
@@ -260,17 +260,20 @@ function read_file($path, $preserve_filepath = FALSE)
if (FALSE !== ($data = file_get_contents($path)))
{
- $name = str_replace("\\", "/", $path);
+ if($name == NULL)

Please can you put a space between the if and the (.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ { // Added a verification to see if it is set, if not set, then it does it's normal thing, if it is set, it uses the defined var.
+ $name = str_replace("\\", "/", $path);
- if ($preserve_filepath === FALSE)
- {
- $name = preg_replace("|.*/(.+)|", "\\1", $name);
+ if ($preserve_filepath === FALSE)
+ {
+ $name = preg_replace("|.*/(.+)|", "\\1", $name);
+ }
}
$this->add_data($name, $data);
return TRUE;
}
- return FALSE;
+ return FALSE;
}
// ------------------------------------------------------------------------
Something went wrong with that request. Please try again.