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. Creating Path /data/print
Forum Updated to NodeBB v4.3 + New Features

Creating Path /data/print

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 406 Views 4 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.
  • F Offline
    F Offline
    fcarney
    wrote on 2 Mar 2020, 20:51 last edited by
    #1

    I have a directory named "/data". I have permissions to this directory (755). The owner is my user name for both group and user. Then I try to do the following:

            QDir path("/data/print");
            if(!path.exists()){
                if(!path.mkdir(".")){
                   // always calling this code as it fails
                   // checked and new directory is not there
                }
            }
    

    I am running Ubuntu 18.04. Qt 5.12.5. 64 bit. mingw.

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 Mar 2020, 20:56 last edited by
      #2

      Hi,

      Why are you using "." for your createDir call ?

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

      F 1 Reply Last reply 2 Mar 2020, 21:03
      0
      • S SGaist
        2 Mar 2020, 20:56

        Hi,

        Why are you using "." for your createDir call ?

        F Offline
        F Offline
        fcarney
        wrote on 2 Mar 2020, 21:03 last edited by
        #3

        @SGaist I tried with and without the '.' The function requires a string. I want it to create the path using the path stored in the QDir object.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcarney
          wrote on 2 Mar 2020, 21:10 last edited by
          #4

          Okay, this works:

          path.mkdir(path.path())
          

          Annoying and redundant, but it works.

          C++ is a perfectly valid school of magic.

          P 1 Reply Last reply 3 Mar 2020, 00:36
          1
          • F fcarney
            2 Mar 2020, 21:10

            Okay, this works:

            path.mkdir(path.path())
            

            Annoying and redundant, but it works.

            P Offline
            P Offline
            Pl45m4
            wrote on 3 Mar 2020, 00:36 last edited by Pl45m4 3 Mar 2020, 00:39
            #5

            @fcarney

            A directory name starting with . will hide the folder. So maybe the directory was there, but you couldn't see it.

            I dont know if QDir or QFile can access hidden dirs or files, so I guess that's the reason why the check failed all the time (if nothing else went wrong)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kent-Dorfman
              wrote on 3 Mar 2020, 01:46 last edited by
              #6

              @Pl45m4 said in Creating Path /data/print:

              I dont know if QDir or QFile can access hidden dirs or files

              Yes, they can.

              I light my way forward with the fires of all the bridges I've burned behind me.

              1 Reply Last reply
              1

              1/6

              2 Mar 2020, 20:51

              • Login

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