note 115706 added to phardata.buildfromiterator
| From: | cbonnissent | Date: | Thu, 11 Sep 2014 19:41:31 +0000 |
| Subject: | note 115706 added to phardata.buildfromiterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200417@lists.php.net to get a copy of this message | ||
The code in the first exemple doesn't work properly without the flag
FilesystemIterator::SKIP_DOTS in the RecursiveDirectoryIterator (on a linux filesystem).
So, to build a tar with a phar, I do (with two level of iteration here) :
$pharTar = new \PharData($contentTar.".tar");
$firstLevelIterator = new \DirectoryIterator($this->inputPath);
foreach ($firstLevelIterator as $fileInfo) {
/* @var \SplFileInfo $fileInfo */
if (in_array($fileInfo->getFilename(), $allowedDirectory)) {
$recursiveDirectoryIterator = new \RecursiveDirectoryIterator(
$this->inputPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(),
\FilesystemIterator::SKIP_DOTS);
$pharTar->buildFromIterator(new
\RecursiveIteratorIterator($recursiveDirectoryIterator), $this->inputPath);
}
}
----
Server IP: 195.221.21.36
Probable Submitter: 78.249.45.81
----
Manual Page -- http://php.net/manual/en/phardata.buildfromiterator.php
Edit -- https://master.php.net/note/edit/115706
Del: integrated -- https://master.php.net/note/delete/115706/integrated
Del: useless -- https://master.php.net/note/delete/115706/useless
Del: bad code -- https://master.php.net/note/delete/115706/bad+code
Del: spam -- https://master.php.net/note/delete/115706/spam
Del: non-english -- https://master.php.net/note/delete/115706/non-english
Del: in docs -- https://master.php.net/note/delete/115706/in+docs
Del: other reasons-- https://master.php.net/note/delete/115706
Reject -- https://master.php.net/note/reject/115706
Search -- https://master.php.net/manage/user-notes.php