Gaufrette\Adapter\Sftp::ensureDirectoryExists PHP Method

ensureDirectoryExists() protected method

Ensures the specified directory exists.
protected ensureDirectoryExists ( string $directory, boolean $create = false )
$directory string The directory that we ensure the existence
$create boolean Whether to create it if it does not exist
    protected function ensureDirectoryExists($directory, $create = false)
    {
        $url = $this->sftp->getUrl($directory);
        $resource = @opendir($url);
        if (false === $resource && (!$create || !$this->createDirectory($directory))) {
            throw new \RuntimeException(sprintf('The directory \'%s\' does not exist and could not be created.', $directory));
        }
        // make sure we don't leak the resource
        if (is_resource($resource)) {
            closedir($resource);
        }
    }