mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
Ref T103, unified isMacOSXBundle
This commit is contained in:
committed by
Mathew Sutcliffe
parent
caf358401f
commit
d25be35868
@@ -51,7 +51,7 @@ namespace BlackMisc
|
||||
Q_ASSERT_X(CBuildConfig::isKnownExecutableName(executable), Q_FUNC_INFO, "Unknown exectuable");
|
||||
|
||||
QString s = CFileUtils::appendFilePaths(CDirectoryUtils::binDirectory(), executable);
|
||||
if (CBuildConfig::isRunningOnMacOSXPlatform() && CDirectoryUtils::isMacOSXAppBundle())
|
||||
if (CDirectoryUtils::isMacOSXAppBundle())
|
||||
{
|
||||
s += QLatin1String(".app/Contents/MacOS/") + executable;
|
||||
}
|
||||
@@ -123,25 +123,19 @@ namespace BlackMisc
|
||||
return p;
|
||||
}
|
||||
|
||||
bool isAppBundleImpl()
|
||||
{
|
||||
QDir bundleDir(CDirectoryUtils::binDirectory());
|
||||
bundleDir.cd("../..");
|
||||
const bool isBundled = QFileInfo(bundleDir.absolutePath()).isBundle();
|
||||
return isBundled;
|
||||
}
|
||||
|
||||
QString getSwiftShareDirImpl()
|
||||
{
|
||||
QDir dir(CDirectoryUtils::binDirectory());
|
||||
bool success = true;
|
||||
|
||||
static const bool appBundle = isAppBundleImpl();
|
||||
if (CBuildConfig::isRunningOnMacOSXPlatform() && appBundle)
|
||||
if (CDirectoryUtils::isMacOSXAppBundle())
|
||||
{
|
||||
success = dir.cd("../../../../share");
|
||||
}
|
||||
else { success = dir.cd("../share"); }
|
||||
else
|
||||
{
|
||||
success = dir.cd("../share");
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,10 @@ namespace BlackMisc
|
||||
//! swift application data sub directories
|
||||
static QStringList applicationDataDirectoryList(bool withoutCurrent = false, bool beautify = false);
|
||||
|
||||
//! Is MacOSX application bundle?
|
||||
//! \remark: Means the currently running executable is a MacOSX bundle, but not all our executables are bundles on MacOSX
|
||||
static bool isMacOSXAppBundle();
|
||||
|
||||
//! swift application data directory for one specific installation (a version)
|
||||
static const QString &normalizedApplicationDataDirectory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user