mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Ref T125, utility functions
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c6f3a7033d
commit
329b0512eb
@@ -52,6 +52,16 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFileUtils::writeByteArrayToFile(const QByteArray &data, const QString &fileNameAndPath)
|
||||
{
|
||||
if (fileNameAndPath.isEmpty()) { return false; }
|
||||
QFile file(fileNameAndPath);
|
||||
if (!file.open(QIODevice::WriteOnly)) { return false; }
|
||||
qint64 c = file.write(data);
|
||||
file.close();
|
||||
return c == data.count();
|
||||
}
|
||||
|
||||
bool CFileUtils::writeStringToLockedFile(const QString &content, const QString &fileNameAndPath)
|
||||
{
|
||||
QLockFile lock(fileNameAndPath + ".lock");
|
||||
|
||||
@@ -60,6 +60,9 @@ namespace BlackMisc
|
||||
//! Write string to text file in background
|
||||
static bool writeStringToFileInBackground(const QString &content, const QString &fileNameAndPath);
|
||||
|
||||
//! Write byte array to file
|
||||
static bool writeByteArrayToFile(const QByteArray &data, const QString &fileNameAndPath);
|
||||
|
||||
//! Append file paths
|
||||
//! \sa CNetworkUtils::buildUrl for URLs
|
||||
static QString appendFilePaths(const QString &path1, const QString &path2);
|
||||
|
||||
@@ -37,6 +37,11 @@ namespace BlackMisc
|
||||
return this->m_simulatorDirectory;
|
||||
}
|
||||
|
||||
bool CSimulatorSettings::hasSimulatorDirectory() const
|
||||
{
|
||||
return !getSimulatorDirectory().isEmpty();
|
||||
}
|
||||
|
||||
void CSimulatorSettings::setModelDirectories(const QStringList &modelDirectories)
|
||||
{
|
||||
this->m_modelDirectories = modelDirectories;
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace BlackMisc
|
||||
//! Simulator directory
|
||||
const QString &getSimulatorDirectory() const;
|
||||
|
||||
//! Setting has simulator setting
|
||||
bool hasSimulatorDirectory() const;
|
||||
|
||||
//! Set model directories
|
||||
void setModelDirectories(const QStringList &modelDirectories);
|
||||
|
||||
|
||||
@@ -119,7 +119,13 @@ namespace BlackMisc
|
||||
{
|
||||
const QString xp = xplaneRootDir();
|
||||
if (xp.isEmpty()) { return xp; }
|
||||
return CFileUtils::appendFilePaths(xp, "/Resources/plugins");
|
||||
return CFileUtils::appendFilePaths(xp, xplanePluginPath());
|
||||
}
|
||||
|
||||
QString CXPlaneUtil::xplanePluginPath()
|
||||
{
|
||||
static const QString p("/Resources/plugins");
|
||||
return p;
|
||||
}
|
||||
|
||||
bool CXPlaneUtil::isXplanePluginDirDirExisting()
|
||||
|
||||
@@ -45,10 +45,13 @@ namespace BlackMisc
|
||||
//! Is the xplaneRootDir existing?
|
||||
static bool isXplaneRootDirExisting();
|
||||
|
||||
//! XPlane root directory
|
||||
//! XPlane plugin directory
|
||||
//! In case more then one XPlane version is found, the path to the highest version is used
|
||||
static QString xplanePluginDir();
|
||||
|
||||
//! XPlane relative plugin path
|
||||
static QString xplanePluginPath();
|
||||
|
||||
//! Is the xplanePluginDir existing?
|
||||
static bool isXplanePluginDirDirExisting();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user