下你所需,载你所想!
汇集开发技术源码资料

QT5 阻塞式封装的FTP组件

:52.248KB :1 :2022-10-09 14:48:38

部分简介

QT5 阻塞式封装的FTP组件如果开发者对于本文件有需要的可以参考。
QT5基于socket实现封装的阻塞式FTP组件,包含目录功能,比QT5自带的要好用无数倍。相比其他的第三方刚FTP组件,容错处理更灵活。
class CFtpInterface: public QObject
{
Q_OBJECT
public:
explicit CFtpInterface(QWidget *parent = 0);
~CFtpInterface();

int connectToHost(const QString &host, quint16 port, bool showmsg=true);
int login(const QString &username, const QString &password, bool showmsg=true);
int changeDir(const QString &strDirPath, bool showmsg=true);
int listFile( );
int abort( );
int uploadFile(const QString &strLocFilePath, bool showmsg=true); // 上传文件到服务器端
int downloadFile(const QString &strLocFilePath, bool showmsg=true); // 下载文件
int uploadFileList(QList> &mapUrl_File); // 上传到服务器端
int downloadFileList(QList> &mapUrl_File);
int deleteFile(const QString &strFileName, bool showmsg=true);
int createDir(const QString &dir, bool showmsg=true);
int deleteDir(const QString &dir, bool showmsg=true);
int renameFile(const QString &oldname, const QString &newname, bool showmsg=true);
bool isConnected();
bool isLoggedIn();
QString errorString();
QMap mapUrlInfo() {return m_listfile;}
QString currentPath() {return m_currentPath;}
int connectToFtp(const QString &host);
private slots:
void ftpCommandFinished(int commandId, bool error);
void addToList(const QUrlInfo &urlInfo);
void updateDTProgress(qint64 readBytes, qint64 totalBytes);
private:
QFtp *m_ftp;
QProgressDialog *m_progress;
QFile *m_file;
int m_retval;
QMap m_listfile;
QString m_currentPath;
QString m_hostIP;
QString m_username;
QString m_password;

};

QT5 阻塞式封装的FTP组件

热门推荐

相关文章