Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcoreapplication_mac.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6#include "private/qcoreapplication_p.h"
7#include <private/qcore_mac_p.h>
8
9#include <qfileinfo.h>
10
11QT_BEGIN_NAMESPACE
12
13/*****************************************************************************
14 QCoreApplication utility functions
15 *****************************************************************************/
16QString qAppFileName()
17{
18 // QCoreApplication::applicationFilePath() expects a canonical path
19 QString appFileName;
20 QCFType<CFURLRef> bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
21 if (bundleURL) {
22 QCFString cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
23 if (cfPath)
24 appFileName = QFileInfo(cfPath).canonicalFilePath();
25 }
26 return appFileName;
27}
28
29QT_END_NAMESPACE