我正在使用以下功能创建一个 tar 存档
public static function packDirectory($path, $outpath) {
require_once 'Archive/Tar.php';
$obj = new Archive_Tar($outpath);
$obj->setErrorHandling(PEAR_ERROR_PRINT);
$handle=opendir($path);
$files = array();
while (false !== ($file = readdir($handle))) {
if ($file == '.' || $file == '..') {
continue;
}
$files[] = $path . '/' . $file;
}
$obj->create($files);
}
路径类似于folder1/folder2/folder3/
. 它会创建一个如下所示的存档
folder1/folder2/folder3/fileA
folder1/folder2/folder3/fileB
folder1/folder2/folder3/fileC
folder1/folder2/folder3/subfolder/fileD
我希望那是
fileA
fileB
fileC
subfolder/fileD
怎么做?