Last active
April 20, 2016 08:52
-
-
Save tyage/0204be0640f14daf601f to your computer and use it in GitHub Desktop.
ZipArchive少し変?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
php -v # => PHP 5.5.9-1ubuntu4.14 | |
mkdir -p /tmp/test | |
touch /tmp/test/foo | |
php zip.php | |
unzip -l /tmp/archive.zip | |
# result: foo -> prefix/oo | |
# Archive: /tmp/archive.zip | |
# Length Date Time Name | |
# --------- ---------- ----- ---- | |
# 0 2016-03-27 19:49 prefix/oo | |
# --------- ------- | |
# 0 1 file | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$zip = new ZipArchive(); | |
$zip->open('/tmp/archive.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); | |
$zip->addGlob('/tmp/test/foo', 0, ['add_path'=>'prefix/','remove_path' => '/tmp/test/']); | |
$zip->close(); |
テストは remove_path: dirname, add_path: 'baz/'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/php/php-src/blob/1c295d4a9ac78fcc2f77d6695987598bb7abcb83/ext/zip/php_zip.c#L1680
remove_path_len + 1
なので、確かにこうなりそう