* @copyright Copyright 2009, James Frasca, All Rights Reserved * @package Package */ // Get the base path for the r8 files $base = realpath(rtrim(__DIR__, "/") . "/..") . "/"; // include r8 require_once $base . 'src/RoundEights.php'; // Create the phar file include "make.php"; // Pull the base temporary directory. Keep creating directory names // until we find one that doesn't yet exist do { $tempDir = new \r8\FileSys\Dir(rtrim(sys_get_temp_dir(), "/") . "/RoundEights_" . uniqid()); } while ($tempDir->isDir()); // Pull the destination directory that the package will be pooled in $dest = new \r8\FileSys\Dir($tempDir->getSubPath("RoundEights")->getPath()); // Create the destination dir $dest->make(); echo "Temporary directory created: " . $dest->getPath() . "\n"; // Pull a list of dirs and files that need to be copied and their destination $copy = array("src" => "", "tests" => "", "README.md" => "README.txt", "LICENSE.md" => "LICENSE.txt", "tools/RoundEights-" . r8_VERSION . ".phar" => ""); // Copy the above files foreach ($copy as $source => $destination) { echo "Copying: " . $source . " "; if (!file_exists($base . $source)) { die("\nCould not locate required path: " . $base . $source); } $result = system("cp -R " . escapeshellarg($base . $source) . " " . escapeshellarg($dest->getSubPath($destination)->getPath())); if ($result === FALSE) { die("Failed"); }
public function testRecursiveIteration_noDots() { $dir = new \r8\FileSys\Dir($this->dir); $dir->setIncludeDots(FALSE); $files = array(); $dirs = array(); $keys = array(); $i = 0; foreach (new RecursiveIteratorIterator($dir) as $key => $item) { $keys[] = $key; if ($item instanceof \r8\FileSys\Dir) { $dirs[] = $item->getBasename(); } else { if ($item instanceof \r8\FileSys\File) { $files[] = $item->getBasename(); } } $i++; if ($i >= 21) { $this->fail("Maximum iterations reached"); } } $this->assertSame(0, count($dirs)); $this->assertContains("one", $files); $this->assertContains("two", $files); $this->assertContains("three", $files); $this->assertContains("four", $files); $this->assertContains("second-one", $files); $this->assertContains("third-one", $files); $this->assertContains("third-two", $files); $this->assertContains("third-three", $files); $this->assertContains("fourth-one", $files); $this->assertContains("fourth-two", $files); $this->assertSame(10, count($files)); }