Wrapper fo ftp_cdup().

@throws \RuntimeException
546648
protected function doCdUp()
    {
        $connection = $this->connection;

        return $this->retry(function () use ($connection) {
            $res = @ftp_cdup($connection);

            if (false === $res) {
                throw new \RuntimeException("Cdup failed");
            }
        });
    }
543434
protected function applyOpenBaseDirSetting() {
		if($this->openBaseDirs) {
			$value = implode(PATH_SEPARATOR, $this->openBaseDirs);
			if(ini_get('open_basedir') != $value) {
				$this->forcePhpConsoleClassesAutoLoad();
				if(ini_set('open_basedir', $value) === false) {
					throw new \Exception('Unable to set "open_basedir" php.ini setting');
				}
			}
		}
	}
1005141
private function checkDir() : void
    {
        $dir = dirname($this->path);
        if (!is_dir($dir)) {
            if (file_exists($dir)) {
                throw new \RuntimeException($dir . ' exists and is not a directory.');
            }
            if (!@mkdir($dir, 0755, true)) {
                throw new \RuntimeException($dir . ' does not exist and could not be created.');
            }
        }
    }
326988
protected function checkOutput($output, $command)
    {
        // the output file must exist
        if (!$this->fileExists($output)) {
            throw new \RuntimeException(sprintf(
                'The file \'%s\' was not created (command: %s).',
                $output, $command
            ));
        }

        // the output file must not be empty
        if (0 === $this->filesize($output)) {
            throw new \RuntimeException(sprintf(
                'The file \'%s\' was created but is empty (command: %s).',
                $output, $command
            ));
        }
    }
272049
protected static function updateRoutingFile( $filename )
	{
		$content = '';

		if( file_exists( $filename ) && ( $content = file_get_contents( $filename ) ) === false ) {
			throw new \RuntimeException( sprintf( 'File "%1$s" not readable', $filename ) );
		}

		if( strpos( $content, 'fos_user:' ) === false )
		{
			$content .= "\n" . 'fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"';
		}

		if( strpos( $content, 'aimeos_shop:' ) === false )
		{
			$content .= "\n" . 'aimeos_shop:
    resource: "@AimeosShopBundle/Resources/config/routing.yml"
    prefix: /';
		}

		$fs = new Filesystem();
		$fs->dumpFile( $filename, $content );
	}
264847
public function run(): void
    {
        if (!$this->config->isLoadedFromFile()) {
            throw new \RuntimeException('No configuration to edit');
        }

        $this->checkHook();
        $this->checkChange();

        $change = $this->createChange();
        $change->applyTo($this->config);
        Config\Util::writeToDisk($this->config);

        $this->io->write('Configuration successfully updated');
    }
963799
public function run()
    {
        if(version_compare(SWOOLE_VERSION, '4.1', '>='))
        {
            \Swoole\Runtime::enableCoroutine(true);
        }
        if(file_exists($this->socketFile))
        {
            unlink($this->socketFile);
        }
        go(function(){
            $this->socket = stream_socket_server('unix://' . $this->socketFile, $errno, $errstr);
            if(false === $this->socket)
            {
                throw new \RuntimeException(sprintf('Create unix socket server failed, errno: %s, errstr: %s', $errno, $errstr));
            }
            while(true)
            {
                $conn = stream_socket_accept($this->socket, 0);
                if(false === $conn)
                {
                    continue;
                }
                go(function() use($conn){
                    $this->parseConn($conn);
                });
            }
        });
    }
288861
public function createOutputDir()
    {
        $outputDir = $this->configuration->get('output');

        if (!is_writable($outputDir)) {
            @mkdir($outputDir, 0777, true);

            if (!is_writable($outputDir)) {
                throw new \RuntimeException("Output directory {$outputDir} is not writable.");
            }
        }
    }
833317
public function run(): void
    {
        if ('' === (string)$this->catName) {
            throw new \RuntimeException('You must call setCatName before running this action');
        }
        if ('' === (string)$this->name) {
            throw new \RuntimeException('You must call setName before running this action');
        }
        $this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
    }
54066
public function initialize()
    {
        if ($this->isActive()) {
            throw new RuntimeException('Process is already active');
        }

        $handle = $this->getFileResource();

        if (! @flock($handle, (LOCK_EX | LOCK_NB))) {
            throw new RuntimeException('Could not lock pidfile');
        }

        if (-1 === @fseek($handle, 0)) {
            throw new RuntimeException('Could not seek pidfile cursor');
        }

        if (! @ftruncate($handle, 0)) {
            throw new RuntimeException('Could not truncate pidfile');
        }

        if (! @fwrite($handle, $this->control->info()->getId().PHP_EOL)) {
            throw new RuntimeException('Could not write on pidfile');
        }
    }
640241
public void goUpDir() throws IOException, ServerException {
        try {
            controlChannel.execute(Command.CDUP);
            // alternative: changeDir("..");
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(
                                urce,
                                "Server refused changing current directory");
        }
    }
575574
protected function sftpUploadFile(): FunctionsInterface
    {
        /* the directory structure on remote host must exist to SFTP */
        if ($this->get('_localFileSize') > 0) {
            $this->get('_sftp')->uploadFile($this->get('_remoteFilePath'), $this->get('_localCacheFilePath'));
        }

        return $this;
    }
442366
public function createDirectory($directory)
    {
        // create parent directory if needed
        $parent = dirname($directory);
        if (!$this->directoryExists($parent)) {
            $this->createDirectory($parent);
        }

        if (ftp_mkdir($this->connection(), $directory) === false) {
            throw new \RuntimeException(sprintf(
                'Could not create directory \'%s\'.',
                $directory
            ));
        }

        return true;
    }
1261732
private function setConnectionPassiveMode()
    {
        if (!ftp_pasv($this->connection, $this->use_passive_mode)) {
            throw new RuntimeException(
                'Could not set passive mode for connection: '
                . $this->config['hostname'] . '::' . $this->config['port']
            );
        }
    }
946353
public function run()
	{
		$this->say('Uploading ' . $this->getJConfig()->extension . $this->getJConfig()->version . " via FTP");

		// Todo Move filepath and name to config
		$this->filename = $this->getExtensionName() . "-" . $this->getJConfig()->version . ".zip";
		$this->filepath = JPATH_BASE . "/dist/" . $this->filename;

		// Check if we have a package
		if (in_array("package", explode(" ", $this->getJConfig()->target)))
		{
			$this->target   = "package";
			$this->filename = "pkg-" . $this->getExtensionName() . "-" . $this->getJConfig()->version . ".zip";
			$this->filepath = JPATH_BASE . "/dist/" . $this->filename;
		}

		try
		{
			if ($this->getJConfig()->ftp->ssl == "true")
			{
				$con = ftp_ssl_connect($this->getJConfig()->ftp->host);
			}
			else
			{
				$con = ftp_connect($this->getJConfig()->ftp->host);
			}

			$login_result = ftp_login($con, $this->getJConfig()->ftp->user, $this->getJConfig()->ftp->password);

			// Set passive ftp
			ftp_pasv($con, true);

			if (!$login_result)
			{
				return Result::error($this, 'Failed logging in');
			}

			ftp_chdir($con, $this->getJConfig()->ftp->target);

			$this->say('Uploading ' . $this->filepath);

			if (!ftp_put($con, $this->filename, $this->filepath, FTP_BINARY))
			{
				return Result::error($this, 'Failed uploading package');
			}

			$this->say("Upload finished");
		}
		catch (\Exception $e)
		{
			return Result::error($this, 'Error: ' . $e->getMessage());
		}

		return true;
	}
363039
private function createFileHandler()
    {
        $path = sprintf($this->config["destination"], time(), date($this->config["datetimeFormat"]));

        $this->destinationHandler = @fopen($path, $this->config["writeMode"]);
        if (!$this->config["blocking"]) {
            stream_set_blocking($this->destinationHandler, (int)$this->config["blocking"]);
        }

        if (!$this->destinationHandler) {
            throw new RuntimeException("Failed to open file $path created from " . $this->config["destination"] . " expression (mode: " . $this->config["writeMode"] . ")");
        }
    }
595064
protected function doExecute()
    {
        $root = $this->io->getArgument(0, WINDWALKER_ROOT . '/src');

        $dirs = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root));

        $count = 0;

        foreach ($dirs as $file) {
            /** @var $file \SplFileInfo */
            if (!$file->isFile() || $file->getExtension() != 'php') {
                continue;
            }

            $content = file_get_contents($file);

            $length = strlen($content);

            $lastChar = $content[$length - 1];

            if ($lastChar == "\n") {
                continue;
            }

            $count++;

            $this->out('Add new line to: ' . $file);

            switch ($lastChar) {
                case ' ' :
                    $content = substr($content, 0, -1);
                    break;

                case '}' :
                    $content .= "\n";
                    break;
            }

            file_put_contents($file, $content);
        }

        if ($count) {
            $this->out($count . ' files add new line.');
        } else {
            $this->out('No file found.');
        }
    }