Results 1 to 3 of 3

Thread: Copy folder recursively from Remote Server to Host machine using Qftp protocol

  1. #1
    Join Date
    Sep 2016
    Posts
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Copy folder recursively from Remote Server to Host machine using Qftp protocol

    Hi,
    I just want to copy directory recursively instead of files from server machine to host machine ,I am using Qftp protocol for that but i am only able to copy files individually which is not solving my purpose as there are lots of log file that i have to copy.
    Here are the codes that i am using for copying files.

    Qt Code:
    1. ///************test ***
    2. // QFileInfoList
    3.  
    4. QString fileName = fileList->currentItem()->text(0);
    5.  
    6. qDebug()<<"File name is :"<<fileName;
    7.  
    8. if (QFile::exists(fileName)) {
    9. QMessageBox::information(this, tr("FTP"),
    10. tr("There already exists a file called %1 in "
    11. "the current directory.")
    12. .arg(fileName));
    13. return;
    14. }
    15.  
    16. file = new QFile(fileName);
    17. if (!file->open(QIODevice::WriteOnly)) {
    18. QMessageBox::information(this, tr("FTP"),
    19. tr("Unable to save the file %1: %2.")
    20. .arg(fileName).arg(file->errorString()));
    21. delete file;
    22. return;
    23. }
    24.  
    25. ftp->get(fileList->currentItem()->text(0), file);
    To copy to clipboard, switch view to plain text mode 

    please help as i am stuck .
    Last edited by anda_skoa; 19th September 2016 at 08:31. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Copy folder recursively from Remote Server to Host machine using Qftp protocol

    There doesn't seem to be any recursion in your code, not even any hint of listing a directory on the server and processing its files.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2016
    Posts
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Copy folder recursively from Remote Server to Host machine using Qftp protocol

    No its not,i my code i am just able to copy selected file only ,but there suppose to be lots of file there so its pain to select and copy each file individually. so i just want to copy whole directory.
    I hope my point is clear to you.
    Thanks for your time and consideration.
    And here is my get function code
    int QFtp::get(const QString &file, QIODevice *dev, TransferType type)
    {
    QStringList cmds;
    if (type == Binary)
    cmds << QLatin1String("TYPE I\r\n");
    else
    cmds << QLatin1String("TYPE A\r\n");
    cmds << QLatin1String("SIZE ") + file + QLatin1String("\r\n");
    cmds << QLatin1String(d->transferMode == Passive ? "PASV\r\n" : "PORT\r\n");
    cmds << QLatin1String("RETR ") + file + QLatin1String("\r\n");
    return d->addCommand(new QFtpCommand(Get, cmds, dev));
    }

    void FtpWindow::downloadFile()
    {

    progressDialog->setVisible(true);
    //progressDialog = new QProgressDialog(this);

    ///************test ***
    // QFileInfoList

    QString fileName = fileList->currentItem()->text(0);

    qDebug()<<"File name is :"<<fileName;

    if (QFile::exists(fileName)) {
    QMessageBox::information(this, tr("FTP"),
    tr("There already exists a file called %1 in "
    "the current directory.")
    .arg(fileName));
    return;
    }

    file = new QFile(fileName);
    if (!file->open(QIODevice::WriteOnly)) {
    QMessageBox::information(this, tr("FTP"),
    tr("Unable to save the file %1: %2.")
    .arg(fileName).arg(file->errorString()));
    delete file;
    return;
    }

    ftp->get(fileList->currentItem()->text(0), file);


    progressDialog->setLabelText(tr("Downloading %1...").arg(fileName));
    downloadButton->setEnabled(false);
    progressDialog->exec();
    }

Similar Threads

  1. Remote host closed error
    By xeyos in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2014, 07:16
  2. Qt application for remote Debugging on host pc for Beagleboard-xM
    By nilking in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd September 2013, 13:06
  3. QSettings : rename/copy a group recursively
    By Kouillo in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2012, 21:51
  4. QFtp: downloading a whole folder from a remote server.
    By balazsbela in forum Qt Programming
    Replies: 5
    Last Post: 5th August 2007, 09:34
  5. How to determine ip address of remote host?
    By nopalot in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2006, 21:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.