Пример #1
0
 /**
  * Delete a directory
  *
  */
 public function rmdir($dir, $recursive = false)
 {
     if ($recursive) {
         $no_errors = true;
         $cwd = $this->_connection->pwd();
         if (!$this->_connection->chdir($dir)) {
             throw new Exception("chdir(): {$dir}: Not a directory");
         }
         $list = $this->_connection->nlist();
         if (!count($list)) {
             // Go back
             $this->_connection->chdir($pwd);
             return $this->rmdir($dir, false);
         } else {
             foreach ($list as $filename) {
                 if ($this->_connection->chdir($filename)) {
                     // This is a directory
                     $this->_connection->chdir('..');
                     $no_errors = $no_errors && $this->rmdir($filename, $recursive);
                 } else {
                     $no_errors = $no_errors && $this->rm($filename);
                 }
             }
         }
         $no_errors = $no_errors && ($this->_connection->chdir($pwd) && $this->_connection->rmdir($dir));
         return $no_errors;
     } else {
         return $this->_connection->rmdir($dir);
     }
 }
Пример #2
0
 /**
  * Removes an empty directory.
  *
  * @param string $dir
  *
  * @return bool
  */
 public function rmdir($dir)
 {
     switch ($this->_connType) {
         case SftpHelper::TYPE_SFTP:
         default:
             $res = $this->_connection->rmdir($dir);
             break;
         case SftpHelper::TYPE_FTP:
             $res = @ftp_rmdir($this->_connection, $dir);
             break;
     }
     return $res;
 }
 /**
  * Attempts to remove the directory named by the path
  *
  * Removes a directory
  *
  * NOTE: rmdir() does not have a $recursive parameter as mkdir() does ( http://www.php.net/manual/en/streamwrapper.rmdir.php )
  *
  * @param String $path
  * @param Integer $options
  * @return bool
  * @access public
  */
 public function rmdir($path, $options)
 {
     $connection = $this->stream_open($path, NULL, NULL, $opened_path);
     if ($connection === false) {
         return FALSE;
     }
     $rmdir = $this->sftp->rmdir($this->path);
     $this->stream_close();
     return $rmdir;
 }