public function addDirectory($directory, $exclude = null, $strip = true)
    {
        $realpath = realpath($this->path . DIRECTORY_SEPARATOR . $directory);
        $iterator = new \RecursiveDirectoryIterator($realpath, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS);

        if ((is_string($exclude) || is_array($exclude)) && !empty($exclude)) {
            $iterator = new \RecursiveCallbackFilterIterator($iterator, function ($current) use ($exclude, $realpath) {
                if ($current->isDir()) {
                    return true;
                }

                $subpath = substr($current->getPathName(), strlen($realpath) + 1);

                return $this->filter($subpath, (array) $exclude);
            });
        }

        $iterator = new \RecursiveIteratorIterator($iterator);
        foreach ($iterator as $file) {
            $virtualfile = substr($file->getPathName(), strlen($this->path) + 1);
            $this->addFile($virtualfile, $strip);
        }
    }
public function addDirectory($directory, $exclude = null, $strip = true)
    {
        $realpath = realpath($this->path . DIRECTORY_SEPARATOR . $directory);
        $iterator = new \RecursiveDirectoryIterator($realpath, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS);

        if ((is_string($exclude) || is_array($exclude)) && !empty($exclude)) {
            $iterator = new \RecursiveCallbackFilterIterator($iterator, function ($current) use ($exclude, $realpath) {
                if ($current->isDir()) {
                    return true;
                }

                $subpath = substr($current->getPathName(), strlen($realpath) + 1);

                return $this->filter($subpath, (array) $exclude);
            });
        }

        $iterator = new \RecursiveIteratorIterator($iterator);
        foreach ($iterator as $file) {
            $virtualfile = substr($file->getPathName(), strlen($this->path) + 1);
            $this->addFile($virtualfile, $strip);
        }
    }
public function addDirectory ( $ directory , $ exclude = null , $ strip = true ) { $ realpath = realpath ( $ this -> path . DIRECTORY_SEPARATOR . $ directory ) ; $ iterator = new \ RecursiveDirectoryIterator ( $ realpath , \ FilesystemIterator :: SKIP_DOTS | \ FilesystemIterator :: UNIX_PATHS ) ; if ( ( is_string ( $ exclude ) || is_array ( $ exclude ) ) && ! empty ( $ exclude ) ) { $ iterator = new \ RecursiveCallbackFilterIterator ( $ iterator , function ( $ current ) use ( $ exclude , $ realpath ) { if ( $ current -> isDir ( ) ) { return true ; } $ subpath = substr ( $ current -> getPathName ( ) , strlen ( $ realpath ) + 1 ) ; return $ this -> filter ( $ subpath , ( array ) $ exclude ) ; } ) ; } $ iterator = new \ RecursiveIteratorIterator ( $ iterator ) ; foreach ( $ iterator as $ file ) { $ virtualfile = substr ( $ file -> getPathName ( ) , strlen ( $ this -> path ) + 1 ) ; $ this -> addFile ( $ virtualfile , $ strip ) ; } }
Adds files of the given directory recursively.

@param string $directory The name of the directory relative to the project root
@param string|array $exclude List of file name patterns to exclude (optional)
@param bool $strip Strip whitespace (Default: TRUE)
Adds files of the given directory recursively .