基本信息
源码名称:QT5 阻塞式封装的FTP组件
源码大小:0.05M
文件格式:.rar
开发语言:C/C++
更新时间:2021-10-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

   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<QPair<QString, QString>> &mapUrl_File);                // 上传到服务器端
    int downloadFileList(QList<QPair<QString, QString>> &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<QString,QUrlInfo> 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<QString,QUrlInfo> m_listfile;
    QString m_currentPath;
    QString m_hostIP;
    QString m_username;
    QString m_password;
    
};