QT实现SFTP


下载此项目需要结合本人的博客去操作,博客地址,https://blog.csdn.net/qq_37602761/article/details/83587775
资源截图
代码片段和文件信息
/**************************************************************************
**
** This file is part of QSsh
**
** Copyright (c) 2012 LVK
**
** Contact: andres.pagliano@lvklabs.com
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**************************************************************************/

#include 
#include 
#include 
#include 
#include 
//#include “securefileuploader.h“

//void showSyntax();
//QString getPassword();
//void upload(const QString &orig const QString &dest const QString passwd);


int main(int argc char *argv[])
{
    QCoreApplication a(argc argv);
//    if (argc != 3) {
//        showSyntax();
//    }

//    QString orig = argv[1];
//    QString dest = argv[2];
//    //QString passwd = getPassword();

//    upload(orig dest “123456“);
    SZRSFtpTools sftpClient;
    sftpClient.setSftpInfo(“192.168.0.118““szsh““szsh123“);

//    for (int i = 0 ; i < 1000;i++)
//    {

//    }
//    QStringList downLoadFiles;
//    downLoadFiles << “/home/xiao/1.txt“ << “/home/xiao/remote“;
    //sftpClient.downLoadFile(“G:/GO““/home/xiao/1.txt“);
//    sftpClient.downLoadFiles(“G:/GO“downLoadFiles);
    QStringList upLoadFiles;
    upLoadFiles << “G:/GO/1.txt“ << “G:/GO/remote“;
    sftpClient.uploadFiles(“/home/szsh“upLoadFiles);
    //sftpClient.uploadFile(“/home/xiao““G:/GO/1.txt“);

    return a.exec();
}


/*void showSyntax()
{
    std::cerr << “Syntax: “ << std::endl;
    std::cerr << “         SecureUploader local_file username@host:/destination_path“ << std::endl;
    exit(1);
}


QString getPassword()
{
    std::cout << “Password (Warning password will be echoed): “;
    std::string passwd;
    std::cin >> passwd;

    return QString::fromStdString(passwd).trimmed();
}


void upload(const QString &orig const QString &dest const QString passwd)
{
    // Parse destination with format “username@host:/destination“

    QStringList l1 = dest.split(“@“);

    if (l1.size() == 2) {
        QStringList l2 = l1[1].split(“:“);

        if (l2.size() == 2) {
            static SecureFileUploader uploader;
            uploader.upload(orig l2[1] l2[0] l1[0] passwd);
        } else {
            std::cerr << “SecureUploader:  Error invalid parameter “ << dest.toStdString() << std::endl;
            showSyntax();
        }
    } else {
        std::cerr << “SecureUploader:  Error invalid parameter “ << dest.toStdString() << std::endl;
        showSyntax();
    }
}*/

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......      3329  2016-07-03 18:37  QSsh-master.gitignore

     文件         85  2018-10-29 12:13  QSsh-masterexamplesexamples.pro

     文件       2922  2018-10-30 14:29  QSsh-masterexamplesSecureUploadermain.cpp

     文件       6892  2018-10-31 11:41  QSsh-masterexamplesSecureUploadersecurefileuploader.cpp

     文件       2586  2018-10-31 11:41  QSsh-masterexamplesSecureUploadersecurefileuploader.h

     文件        738  2018-10-31 11:36  QSsh-masterexamplesSecureUploaderSecureUploader.pro

     文件       1327  2018-10-31 11:50  QSsh-masterexamplesSecureUploaderSZRSFtpTools.cpp

     文件       1075  2018-10-31 11:50  QSsh-masterexamplesSecureUploaderSZRSFtpTools.h

    .......        59  2016-07-03 18:37  QSsh-masterexamplesssherrorhandlingerrorhandling.pro

    .......      7352  2016-07-03 18:37  QSsh-masterexamplesssherrorhandlingmain.cpp

    .......      6486  2016-07-03 18:37  QSsh-masterexamplesssh
emoteprocessargumentscollector.cpp

    .......      1990  2016-07-03 18:37  QSsh-masterexamplesssh
emoteprocessargumentscollector.h

    .......      1777  2016-07-03 18:37  QSsh-masterexamplesssh
emoteprocessmain.cpp

    .......       153  2016-07-03 18:37  QSsh-masterexamplesssh
emoteprocess
emoteprocess.pro

    .......     12830  2016-07-03 18:37  QSsh-masterexamplesssh
emoteprocess
emoteprocesstest.cpp

    .......      2647  2016-07-03 18:37  QSsh-masterexamplesssh
emoteprocess
emoteprocesstest.h

    .......      6769  2016-07-03 18:37  QSsh-masterexamplessshsftpargumentscollector.cpp

    .......      1972  2016-07-03 18:37  QSsh-masterexamplessshsftpargumentscollector.h

     文件       1776  2018-10-29 16:01  QSsh-masterexamplessshsftpmain.cpp

    .......      1406  2016-07-03 18:37  QSsh-masterexamplessshsftpparameters.h

    .......       146  2016-07-03 18:37  QSsh-masterexamplessshsftpsftp.pro

    .......     24930  2016-07-03 18:37  QSsh-masterexamplessshsftpsftptest.cpp

    .......      3901  2016-07-03 18:37  QSsh-masterexamplessshsftpsftptest.h

    .......      1458  2016-07-03 18:37  QSsh-masterexamplessshsftpfsmodelmain.cpp

    .......       174  2016-07-03 18:37  QSsh-masterexamplessshsftpfsmodelsftpfsmodel.pro

    .......      4246  2016-07-03 18:37  QSsh-masterexamplessshsftpfsmodelwindow.cpp

    .......      1828  2016-07-03 18:37  QSsh-masterexamplessshsftpfsmodelwindow.h

    .......      5728  2016-07-03 18:37  QSsh-masterexamplessshsftpfsmodelwindow.ui

    .......      1746  2016-07-03 18:37  QSsh-masterexamplessshshellmain.cpp

    .......      3691  2016-07-03 18:37  QSsh-masterexamplessshshellshell.cpp

............此处省略141个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)