/** * Remove directory on sftp location * @param string $directory Remote directory path * @param bool $recursive If true remove directory even it is not empty * @return bool true if directory removal success * @throws CException if directory removal fails */ function removeDirectory($directory, $recursive = false) { if ($recursive) { if ($this->objSftp->delete($directory)) { return true; } else { throw new CException(Yii::t('XSFtp.sftp', 'Directory removal failed.')); } } if ($this->objSftp->rmdir($directory)) { return true; } else { throw new CException(Yii::t('XSFtp.sftp', 'Directory removal failed as folder is not empty.')); } }