bool SFtpFileEngine::rename(const QString &newName) { qDebug() << "rename()" << _fileName << _path << newName; if (!sftpConnect()) return false; PathComp fixedNewName(newName); QString newPath(QUrl(fixedNewName.path()).path()); bool result = !libssh2_sftp_rename(_sftp_session, _textCodec->fromUnicode(_path).data(), _textCodec->fromUnicode(newPath).data()); if (result) { _fileInfoCache->renameFileInfo(getCachePath(_path), getCachePath(newPath)); _urlInfo.setName(fixedNewName.fileName()); } sftpDisconnect(); return result; }
int FSSftp::Rename ( FSPath& oldpath, FSPath& newpath, int* err, FSCInfo* info ) { MutexLock lock( &mutex ); int ret = CheckSession( err, info ); if ( ret ) { return ret; } try { int ret; WHILE_EAGAIN_( ret, libssh2_sftp_rename( sftpSession, ( char* ) oldpath.GetString( _operParam.charset, '/' ), ( char* ) newpath.GetString( _operParam.charset, '/' ) ) ); CheckSFTP( ret ); } catch ( int e ) { if ( err ) { *err = e; } return ( e == -2 ) ? -2 : -1; } return 0; }