title: Qt - accessing the bundle path
body: <p>The Qt documentation "<a href="http://doc.qt.nokia.com/4.6/mac-differences.html#mac-os-x-native-api-access" rel="nofollow noreferrer">Mac Differences</a>" page provides the following code for accessing an application's bundle path:</p>
  
  <pre><code>CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
  CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
  const char *pathPtr = CFStringGetCStringPtr(macPath,CFStringGetSystemEncoding());
  qDebug("Path = %s", pathPtr);
  CFRelease(appUrlRef);
  CFRelease(macPath);
  </code></pre>
  
  <p>However, what is the advantage of that over something simpler, like the following:</p>
  
  <pre><code>QDir dir = QDir(QCoreApplication::applicationDirPath());
  dir.cdUp();
  dir.cdUp();
  return dir;
  </code></pre>