Renders a directory recursively.

@param string $dir        Path to the directory that will be recursively rendered
@param array  $parameters
497564
public static function renderDir($dir, array $parameters)
    {
        foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
            if ($file->isFile()) {
                static::renderFile((string) $file, $parameters);
            }
        }
    }
922588
public function setDir($dir)
    {
        if (in_array($dir, Direction::asArray(), true) === true) {
            $this->dir = $dir;
        } else {
            $msg = "The 'dir' argument must be a value from the Direction enumeration.";
            throw new InvalidArgumentException($msg);
        }
    }
861210
public function render($template, $parameters = [])
    {
        if (count($parameters) < 1) {
            $parameters = null;
        }
        echo $this->smarty->fetch($template, $parameters);
    }
1092847
static function recursiveList( $dir, $path, &$fileList )
    {
        if ( $handle = @opendir( $dir ) )
        {
            while ( ( $file = readdir( $handle ) ) !== false )
            {
                if ( ( $file == "." ) || ( $file == ".." ) )
                {
                    continue;
                }
                if ( is_dir( $dir . '/' . $file ) )
                {
                    $fileList[] = array( 'path' => $path, 'name' => $file, 'type' => 'dir' );
                    eZDir::recursiveList( $dir . '/' . $file, $path . '/' . $file, $fileList );
                }
                else
                {
                    $fileList[] = array( 'path' => $path, 'name' => $file, 'type' => 'file'  );
                }
            }
            @closedir( $handle );
        }
    }
1312954
protected function generateDocument($parameters, $dir, $document)
    {
        // doctrine mapping normal class
        $this->renderFile(
            'document/Document.mongodb.yml.twig',
            $dir . '/Resources/config/doctrine/' . $document . '.mongodb.yml',
            $parameters
        );

        // doctrine mapping embedded
        $this->renderFile(
            'document/Document.mongodb.yml.twig',
            $dir . '/Resources/config/doctrine/' . $document . 'Embedded.mongodb.yml',
            array_merge(
                $parameters,
                [
                    'document' => $document.'Embedded',
                    'docType' => 'embeddedDocument'
                ]
            )
        );

        $this->renderFile(
            'document/Document.php.twig',
            $dir . '/Document/' . $document . '.php',
            $parameters
        );
        $this->renderFile(
            'document/DocumentEmbedded.php.twig',
            $dir . '/Document/' . $document . 'Embedded.php',
            $parameters
        );
        $this->renderFile(
            'document/DocumentBase.php.twig',
            $dir . '/Document/' . $document . 'Base.php',
            $parameters
        );

        $this->generateServices($parameters, $dir, $document);
    }
319251
public function setLogDir($dir)
    {
        $dir = str_replace("\\", "/", $dir);
        $dir = rtrim($dir, '/');
        
        $this->logDir = $dir;
    }
1221697
protected function makeFolder($dir)
    {
        if (!is_dir($dir)) {
            $parent = \dirname($dir);
            try {
                $this->makeFolder($parent);
                $this->filesystem->mkdir($dir);
                $this->filesystem->chmod($dir, $this->folderPermissions);
            } catch (IOException $e) {
                throw new \RuntimeException(sprintf('Could not create directory %s', $dir), 0, $e);
            }
        }
    }
656132
private function readDirectoryContent(string $directory): void
    {
        $items = new DirectoryIterator($directory);

        foreach ($items as $item) {

            if ($item->isFile() && $this->isFile($item->getFilename())) {
                $this->readFileContent($item->getPathname());
            }
        }
    }
296806
protected function deleteDirectory($dir)
    {
        $files = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($files as $fileInfo) {
            $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink');

            $todo($fileInfo->getRealPath());
        }

        rmdir($dir);
    }
1076594
public static function createDir(string $dir, int $mode = 0777): void
	{
		NetteFileSystem::createDir($dir, $mode);
	}
454609
protected static function recursiveMakeDirectory(string $dir, int $mode = 0777): bool {
		return (is_dir(dirname($dir)) || static::recursiveMakeDirectory(dirname($dir))) ? mkdir($dir, $mode) : true;
	}
550337
public static function purge(string $dir): void
	{
		if (!is_dir($dir)) {
			mkdir($dir);
		}

		/** @var SplFileInfo $entry */
		foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $entry) {
			if ($entry->isDir()) {
				rmdir((string) $entry->getRealPath());
			} else {
				unlink((string) $entry->getRealPath());
			}
		}
	}
1279505
function( dir ) {
		// Make the root results directory first
		render._mkdir( dir, function( e ) {
			if ( e ) {
				return munit.exit( 1, e, "Failed to make root results directory" );
			}

			// Make a working directory for each format
			async.each( render._formats,
				function( format, callback ) {
					var path = dir + format.name + '/';

					render._mkdir( path, function( e ) {
						if ( e ) {
							callback( e );
						}
						else {
							format.callback( path, callback );
						}
					});
				},
				function( e ) {
					if ( e ) {
						munit.exit( 1, e );
					}
					else {
						render._complete();
					}
				}
			);
		});
	}
311333
public static function addResourceDirectory($prefix, $dir)
    {
        if(self::$_resourceLoader) {
            self::$_resourceLoader->addPrefixPath($prefix, $dir);
        }
    }
425972
public function render($template, array $parameters = null, Response $response = null)
    {
        return parent::render($this->bundle->getBaseDirectory().DIRECTORY_SEPARATOR.'Templates'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.$template, $parameters, $response);
    }
1185689
private function generateIndexView($dir)
    {
        $this->renderFile('views/index.html.twig', $dir.'/index.html.twig', array(
            'dir' => $this->skeletonDir,
            'document' => $this->document,
            'fields' => $this->metadata->fieldMappings,
            'actions' => $this->actions,
            'record_actions' => $this->getRecordActions(),
            'route_prefix' => $this->routePrefix,
            'route_name_prefix' => $this->routeNamePrefix,
        ));
    }
92647
protected function _createDirectory($dir)
    {
        $old = umask(0);
        // @codingStandardsIgnoreStart
        $result = @mkdir($dir, 0755, true);
        // @codingStandardsIgnoreEnd
        umask($old);

        if ($result) {
            $this->out('Created directory ' . $dir);

            return true;
        }

        $this->err('Failed creating directory ' . $dir);

        return false;
    }