本文整理汇总了PHP中Net_SFTP::rmdir方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::rmdir方法的具体用法?PHP Net_SFTP::rmdir怎么用?PHP Net_SFTP::rmdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_SFTP
的用法示例。
在下文中一共展示了Net_SFTP::rmdir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rmdir
/**
* 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: rmdir
/**
* 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;
}
示例3: rmdir
/**
* 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;
}