void clSFTP::RemoveDir(const wxString& dirname) throw (clException) { if ( !m_sftp ) { throw clException("SFTP is not initialized"); } int rc; rc = sftp_rmdir(m_sftp, dirname.mb_str(wxConvISO8859_1).data()); if ( rc != SSH_OK ) { throw clException(wxString() << _("Failed to remove directory: ") << dirname << ". " << ssh_get_error(m_ssh->GetSession()), sftp_get_error(m_sftp)); } }
int FSSftp::RmDir ( FSPath& path, int* err, FSCInfo* info ) { MutexLock lock( &mutex ); int ret = CheckSession( err, info ); if ( ret ) { return ret; } if ( sftp_rmdir( sftpSession, ( char* )path.GetString( _operParam.charset ) ) ) { if ( err ) { *err = sftp_get_error( sftpSession ); } return -1; } return 0; }
int ssh_rmdir(const char *path) { char* abspath = ftp_path_absolute(path); stripslash(abspath); int rc = sftp_rmdir(ftp->sftp_session, abspath); if (rc != SSH_OK && sftp_get_error(ftp->sftp_session) != SSH_FX_NO_SUCH_FILE) { ftp_err(_("Couldn't remove directory: %s\n"), ssh_get_error(ftp->session)); free(abspath); return rc; } ftp_cache_flush_mark(abspath); ftp_cache_flush_mark_for(abspath); free(abspath); return 0; }
static int _sftp_rmdir(const char *uri) { char *path = NULL; int rc = -1; if (_sftp_connect(uri) < 0) { return -1; } if (c_parse_uri(uri, NULL, NULL, NULL, NULL, NULL, &path) < 0) { return -1; } rc = sftp_rmdir(_sftp_session, path); if (rc < 0) { errno = _sftp_portable_to_errno(sftp_get_error(_sftp_session)); } SAFE_FREE(path); return rc; }
static void torture_sftp_mkdir(void **state) { struct torture_sftp *t = *state; char tmpdir[128] = {0}; int rc; assert_false(t == NULL); snprintf(tmpdir, sizeof(tmpdir) - 1, "%s/mkdir_test", t->testdir); rc = sftp_mkdir(t->sftp, tmpdir, 0755); if(rc != SSH_OK) fprintf(stderr,"error:%s\n",ssh_get_error(t->sftp->session)); assert_true(rc == 0); /* check if it really has been created */ assert_true(torture_isdir(tmpdir)); rc = sftp_rmdir(t->sftp, tmpdir); assert_true(rc == 0); /* check if it has been deleted */ assert_false(torture_isdir(tmpdir)); }