Change CService::getAircraftLivery() to return livery without path

CService::getAircraftLivery() is expected to return the livery name itself
without the full path.

ref T378
This commit is contained in:
Roland Winklmeier
2018-10-18 15:01:16 +02:00
committed by Klaus Basan
parent 1fecf65a40
commit 1a63c00a71
3 changed files with 13 additions and 2 deletions

View File

@@ -104,6 +104,16 @@ namespace XSwiftBus
return acfProperties.modelName; return acfProperties.modelName;
} }
std::string CService::getAircraftLivery() const
{
std::string liveryPath = m_liveryPath.get();
if (liveryPath.empty()) { return {}; }
// liveryPath end with / and we need to get rid of it
liveryPath.pop_back();
return getFileName(liveryPath);
}
int CService::getXPlaneVersionMajor() const int CService::getXPlaneVersionMajor() const
{ {
int version; int version;

View File

@@ -79,8 +79,8 @@ namespace XSwiftBus
//! Get name of current aircraft model //! Get name of current aircraft model
std::string getAircraftName() const; std::string getAircraftName() const;
//! Get path to current aircraft livery //! Get current aircraft livery
std::string getAircraftLivery() const { return m_liveryPath.get(); } std::string getAircraftLivery() const;
//! Get the ICAO code of the current aircraft model //! Get the ICAO code of the current aircraft model
std::string getAircraftIcaoCode() const { return m_icao.get(); } std::string getAircraftIcaoCode() const { return m_icao.get(); }

View File

@@ -43,6 +43,7 @@ namespace BlackMiscTest
QCOMPARE(QString::fromStdString(getFileName("foo/test.txt")), QString("test.txt")); QCOMPARE(QString::fromStdString(getFileName("foo/test.txt")), QString("test.txt"));
QCOMPARE(QString::fromStdString(getFileName("test.txt")), QString("test.txt")); QCOMPARE(QString::fromStdString(getFileName("test.txt")), QString("test.txt"));
QCOMPARE(QString::fromStdString(getFileName("foo/test.txt.txt")), QString("test.txt.txt")); QCOMPARE(QString::fromStdString(getFileName("foo/test.txt.txt")), QString("test.txt.txt"));
QCOMPARE(QString::fromStdString(getFileName("foo/bar")), QString("bar"));
} }
void CTestXPlane::getDirNameTest() void CTestXPlane::getDirNameTest()