Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Possible to upload a QDir with QFtp
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Possible to upload a QDir with QFtp

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Woody
    wrote on last edited by
    #1

    Ok what I have atm is that i can check for changed file (date modified, content modified).
    The files that are changed, will be uploaded to the server.

    This all works fine, connects nice, logs me in, etc.

    But now my question is, if it is possible to upload a whole directory?
    So if I add a directory to my folder I'm checking, I don't have to bother about are the files changed.

    Somebody knows more about this?

    Thanks in advance!

    File not found. Nobody leave the room!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on last edited by
      #2

      You will have to implement that yourself, FTP is a File Transfer Protocol, when GUI application seem to transfer a folder, they really do the work of uploading each file separately in the background.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Woody
        wrote on last edited by
        #3

        Well I've found the solution for that problem. But it was quiet complicated.

        I go check my whole folder (local one) and add all the folders to a list:
        @fillFolderInfoList(getLocalDir(), &folderList);

        QFileInfoList fileListRoot(QDir(rootPath).entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs, QDir::Time | QDir::Reversed));
        foreach(QFileInfo fileInfo, fileListRoot)
        {
        if(fileInfo.isDir())
        {
        list->append(fileInfo);
        fillFolderInfoList(fileInfo.filePath(), list);
        }
        }@

        Then I compare the folder with the online list, which I fill up with this:
        @void FtpThread::ftpListInfo(QUrlInfo urlInfo)
        {
        if(urlInfo.isDir())
        {
        if(!m_folderList.contains((m_folder == "" ? "" : m_folder + "/") + urlInfo.name()))
        {
        m_folderList << (m_folder == "" ? "" : m_folder + "/") + urlInfo.name();
        m_ftp->list(urlInfo.name());
        }
        }
        }@

        And if the folder doesn't exist, I just make it:
        @foreach(QFileInfo folderInfo, folderList)
        {
        QString folder = folderInfo.filePath().right(folderInfo.filePath().length() - (getLocalDir().length() + 1));
        if(!m_folderList.contains(folder) && !m_creatingBusy)
        {
        m_folder = folderInfo.filePath().right(folderInfo.filePath().length() - (getLocalDir().length() + 1));
        if(folder.lastIndexOf("/") > -1)
        m_folder = m_folder.left(m_folder.length() - (folder.length() - folder.lastIndexOf("/")));
        else
        m_folder = "";
        m_ftp->mkdir(folder);
        }
        }@

        So everytime something changed on the server, I go check if it is a directory. It's quiet complicated and hard to explain, but I got it working.

        Thanks though for the reply.

        File not found. Nobody leave the room!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved