Skip to content

Instantly share code, notes, and snippets.

@tyage
Created July 15, 2016 02:38
Show Gist options
  • Save tyage/173cac00c035289bd4b55beada67d55d to your computer and use it in GitHub Desktop.
Save tyage/173cac00c035289bd4b55beada67d55d to your computer and use it in GitHub Desktop.
--TEST--
Bug #72374 (ZipArchive::addGlob remove_path option strips first char of filename)
--SKIPIF--
<?php
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$dirname = $dirname . 'bug72374/';
mkdir($dirname);
$file = $dirname . 'some-foo.txt';
touch($file);
$zip = new ZipArchive();
$zip->open($dirname . 'test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->addGlob($file, 0, array('remove_path' => $dirname . 'some-'));
$zip->addGlob($file, 0, array('remove_path' => $dirname));
dump_entries_name($zip);
$zip->close();
?>
--CLEAN--
<?php
$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$dirname = $dirname . 'bug72374/';
rmdir_rf($dirname);
?>
--EXPECTF--
0 foo.txt
1 /some-foo.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment