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] QDir not cd'ing on Mac OS Yosemite
QtWS25 Last Chance

[SOLVED] QDir not cd'ing on Mac OS Yosemite

Scheduled Pinned Locked Moved General and Desktop
qdiryosemitemac os x
7 Posts 4 Posters 2.8k Views
  • 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.
  • E Offline
    E Offline
    echobravo
    wrote on 30 Jun 2015, 23:44 last edited by echobravo
    #1

    Working on an app that needs to cd based off the QCoreApplication::applicationDirPath()
    can get the path to application, but can not cd any where, not even cdUp()...
    I have looked for known issues, but did not have any luck... surely this is something simple blocking me...

    Thanks in advance for any thoughts.

    EB

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MartinH
      wrote on 30 Jun 2015, 23:53 last edited by
      #2

      Hello :) can you show us your code :) ?

      1 Reply Last reply
      0
      • E Offline
        E Offline
        echobravo
        wrote on 1 Jul 2015, 00:08 last edited by
        #3

        QDir dir(QCoreApplication::applicationDirPath());
        if (!dir.exists())
        qWarning("Cannot find the APP directory");
        qWarning("DEBUG: 1. app dir: %s", qPrintable(dir.currentPath()));

        qWarning("DEBUG: 1a readible?: %s", (dir.isReadable() ? "YES" : "NO" ));
        qWarning("DEBUG: 1b absolute?: %s", (dir.isAbsolute() ? "YES" : "NO" ));
        //dir.cdUp(); // was looking into this being an issue of the actual binary being buried in the app package
        //dir.cdUp();
        //dir.cdUp();
        
        
        
        if (!dir.exists("plugins"))
            qWarning("Cannot find the PLUGINS directory");
        //dir.cd("plugins");
        //qWarning("DEBUG: 2.app dir: %s", qPrintable(dir.currentPath()));
        
        //if (!dir.cd(QStringLiteral("plugins"))) {
        if (!dir.cd("plugins")) {
            /// TODO: Better error reporting
            qWarning("WARNING: Cannot find plugins!");
            return;
        }
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          MartinH
          wrote on 1 Jul 2015, 00:17 last edited by
          #4

          Did you forgot brackets on the first conditional statement ?

          E 1 Reply Last reply 1 Jul 2015, 00:27
          0
          • M MartinH
            1 Jul 2015, 00:17

            Did you forgot brackets on the first conditional statement ?

            E Offline
            E Offline
            echobravo
            wrote on 1 Jul 2015, 00:27 last edited by
            #5

            @MartinH it was indented in code, formatting dropped the indent

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rondog
              wrote on 1 Jul 2015, 01:19 last edited by Rondog 7 Jan 2015, 01:21
              #6

              You could try another method. I am a little skeptical that QDir::cdUp() doesn't work but I didn't try it (maybe something related to being inside an app folder ?).

              This will get the folder of the application (assuming the extension is '.app' which should be safe). A variation of this would be to get a specific folder in the application bundle of the container as opposed to trying to move up from the actual application itself.

              	QString d_data_path = qApp->applicationDirPath();
              
              // remove everything past '.app'
              	int index = d_data_path.lastIndexOf(".app/");
              	d_data_path.truncate(index);
              	
              // remove name of application, whatever it is called
              	index = d_data_path.lastIndexOf('/');
              	d_data_path.truncate(index);
              

              It may be possible to get the 'plugins' folder by some other means. I know Qt can find it when the application is packaged properly (using macdeployqt).

              One last thought. If you didn't package the application (manually or using macdeployqt) then you may not have a plugins folder inside the application. You should manually check to see it exists inside the application bundle.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ambershark
                wrote on 1 Jul 2015, 05:17 last edited by
                #7

                You can check your directory by doing:

                qDebug() << dir.absolutePath();
                dir.cdUp();
                qDebug() << dir.absolutePath();
                

                That should tell you what's happening and why. I have used QDir specifically to navigate inside bundles on Mavericks and it worked so check what those values are and it might show you the problem.

                My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                1 Reply Last reply
                1

                4/7

                1 Jul 2015, 00:17

                • Login

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