mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +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;
|
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)
|
bool CFileUtils::writeStringToLockedFile(const QString &content, const QString &fileNameAndPath)
|
||||||
{
|
{
|
||||||
QLockFile lock(fileNameAndPath + ".lock");
|
QLockFile lock(fileNameAndPath + ".lock");
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ namespace BlackMisc
|
|||||||
//! Write string to text file in background
|
//! Write string to text file in background
|
||||||
static bool writeStringToFileInBackground(const QString &content, const QString &fileNameAndPath);
|
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
|
//! Append file paths
|
||||||
//! \sa CNetworkUtils::buildUrl for URLs
|
//! \sa CNetworkUtils::buildUrl for URLs
|
||||||
static QString appendFilePaths(const QString &path1, const QString &path2);
|
static QString appendFilePaths(const QString &path1, const QString &path2);
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ namespace BlackMisc
|
|||||||
return this->m_simulatorDirectory;
|
return this->m_simulatorDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorSettings::hasSimulatorDirectory() const
|
||||||
|
{
|
||||||
|
return !getSimulatorDirectory().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorSettings::setModelDirectories(const QStringList &modelDirectories)
|
void CSimulatorSettings::setModelDirectories(const QStringList &modelDirectories)
|
||||||
{
|
{
|
||||||
this->m_modelDirectories = modelDirectories;
|
this->m_modelDirectories = modelDirectories;
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ namespace BlackMisc
|
|||||||
//! Simulator directory
|
//! Simulator directory
|
||||||
const QString &getSimulatorDirectory() const;
|
const QString &getSimulatorDirectory() const;
|
||||||
|
|
||||||
|
//! Setting has simulator setting
|
||||||
|
bool hasSimulatorDirectory() const;
|
||||||
|
|
||||||
//! Set model directories
|
//! Set model directories
|
||||||
void setModelDirectories(const QStringList &modelDirectories);
|
void setModelDirectories(const QStringList &modelDirectories);
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,13 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
const QString xp = xplaneRootDir();
|
const QString xp = xplaneRootDir();
|
||||||
if (xp.isEmpty()) { return xp; }
|
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()
|
bool CXPlaneUtil::isXplanePluginDirDirExisting()
|
||||||
|
|||||||
@@ -45,10 +45,13 @@ namespace BlackMisc
|
|||||||
//! Is the xplaneRootDir existing?
|
//! Is the xplaneRootDir existing?
|
||||||
static bool isXplaneRootDirExisting();
|
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
|
//! In case more then one XPlane version is found, the path to the highest version is used
|
||||||
static QString xplanePluginDir();
|
static QString xplanePluginDir();
|
||||||
|
|
||||||
|
//! XPlane relative plugin path
|
||||||
|
static QString xplanePluginPath();
|
||||||
|
|
||||||
//! Is the xplanePluginDir existing?
|
//! Is the xplanePluginDir existing?
|
||||||
static bool isXplanePluginDirDirExisting();
|
static bool isXplanePluginDirDirExisting();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user