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. How to effectively overwrite entire folders in Qt C++?
Forum Updated to NodeBB v4.3 + New Features

How to effectively overwrite entire folders in Qt C++?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 408 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.
  • H Offline
    H Offline
    heftlas
    wrote on 19 Sept 2022, 18:15 last edited by
    #1

    Hello!

    If I have two QDir objects

    QDir source;
    QDir destiny;
    

    How can I effectively overwrite source into destiny using Qt?

    I want every existing file to be overwritten (the source version will be copied onto destiny) and any folders that are not present at destiny should be copied.

    I couldn't find in the documentation anything specifically for that. Am I missing something?

    Do I have to actually just iterate through every file in source and then remove/copy onto destiny?
    Then if it's a folder do I have to actually QDir::cd into them and do the same thing (if it exists at destiny)?

    I'm asking here because I think I'm missing something. Isn't there something like QDir::rename that actually works when directories already exist?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Sept 2022, 18:34 last edited by
      #4

      Then you can use QDirIterator to go through your source folder and copy files/create folder based on what it provides you.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply 19 Sept 2022, 19:06
      1
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 19 Sept 2022, 18:20 last edited by
        #2

        Hi,

        Are you trying to reimplement something like the rsync utility ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • H Offline
          H Offline
          heftlas
          wrote on 19 Sept 2022, 18:27 last edited by
          #3

          @SGaist Nope! I just really want to overwrite a folder onto another.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 19 Sept 2022, 18:34 last edited by
            #4

            Then you can use QDirIterator to go through your source folder and copy files/create folder based on what it provides you.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            H 1 Reply Last reply 19 Sept 2022, 19:06
            1
            • S SGaist
              19 Sept 2022, 18:34

              Then you can use QDirIterator to go through your source folder and copy files/create folder based on what it provides you.

              H Offline
              H Offline
              heftlas
              wrote on 19 Sept 2022, 19:06 last edited by
              #5

              @SGaist Thank you! I did it using QDir::entryInfoList but I guess QDirIterator would be much better.

              1 Reply Last reply
              0

              1/5

              19 Sept 2022, 18:15

              • Login

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