Php 当tar内容具有相对路径时,PharData类失败
我在使用Phar访问Gzip tar文件时遇到问题 以下是我的测试代码:Php 当tar内容具有相对路径时,PharData类失败,php,phar,Php,Phar,我在使用Phar访问Gzip tar文件时遇到问题 以下是我的测试代码: <?php function r($a) { print " has " . count($a) . " files:\n"; foreach (new RecursiveIteratorIterator($a) as $path => $fileinfo) { print " " . $path . "\n"; } } print "\n1.tgz"; r(new PharData
<?php
function r($a) {
print " has " . count($a) . " files:\n";
foreach (new RecursiveIteratorIterator($a) as $path => $fileinfo) {
print " " . $path . "\n";
}
}
print "\n1.tgz";
r(new PharData('1.tgz'));
print "\n2.tgz";
r(new PharData('2.tgz'));
print "\norig dir:";
chdir('orig-dir');
r(new RecursiveDirectoryIterator('./'));
以下是输出:
1.tgz has 4 files:
phar:///tmp/t/1.tgz/a
phar:///tmp/t/1.tgz/b
phar:///tmp/t/1.tgz/subdir/c
2.tgz has 5 files:
orig dir: has 1 files:
./b
./.
./subdir/.
./subdir/c
./subdir/..
./..
./a
问:为什么phar在处理第二个tar文件时遇到如此困难?(我使用的是PHP5.6)很抱歉,您遇到了这些问题。。。我也是。看起来我可能无法将
PharData
用于我的特定用例:(
1.tgz has 4 files:
phar:///tmp/t/1.tgz/a
phar:///tmp/t/1.tgz/b
phar:///tmp/t/1.tgz/subdir/c
2.tgz has 5 files:
orig dir: has 1 files:
./b
./.
./subdir/.
./subdir/c
./subdir/..
./..
./a