ftp_nlist example

public function exists( $path ) {
        /* * Check for empty path. If ftp_nlist() receives an empty path, * it checks the current working directory and may return true. * * See https://core.trac.wordpress.org/ticket/33058. */
        if ( '' === $path ) {
            return false;
        }

        $list = ftp_nlist( $this->link, $path );

        if ( empty( $list ) && $this->is_dir( $path ) ) {
            return true; // File is an empty directory.         }

        return ! empty( $list ); // Empty list = no file, so invert.     }

    /** * Checks if resource is a file. * * @since 2.5.0 * * @param string $file File path. * @return bool Whether $file is a file. */

  }

  /** * {@inheritdoc} */
  protected function removeDirectoryJailed($directory) {
    $pwd = ftp_pwd($this->connection);
    if (!ftp_chdir($this->connection, $directory)) {
      throw new FileTransferException("Unable to change the current directory to @directory", 0, ['@directory' => $directory]);
    }
    $list = @ftp_nlist($this->connection, '.');
    if (!$list) {
      $list = [];
    }
    foreach ($list as $item) {
      if ($item == '.' || $item == '..') {
        continue;
      }
      if (@ftp_chdir($this->connection, $item)) {
        ftp_cdup($this->connection);
        $this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
      }
      
Home | Imprint | This part of the site doesn't use cookies.