mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 15:15:39 +08:00
Fix parsing of X-Plane ACF file headers
So far the 'version' literal was compared case sensitive. So we did not parse ACF files which had a capitalized literal. Instead the comparison should be case insensitive. To do that we convert all strings to lower case before comparing. ref T378
This commit is contained in:
committed by
Klaus Basan
parent
92790f1330
commit
1fecf65a40
@@ -15,6 +15,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cctype>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
// Strict header only X-Plane model parser utils shared between BlackMisc and XSwiftBus.
|
// Strict header only X-Plane model parser utils shared between BlackMisc and XSwiftBus.
|
||||||
// Header only is necessary to no require XSwiftBus to link against BlackMisc.
|
// Header only is necessary to no require XSwiftBus to link against BlackMisc.
|
||||||
@@ -118,6 +120,15 @@ namespace BlackMisc
|
|||||||
return getDirName(acfFile) + ' ' + getBaseName(acfFile);
|
return getDirName(acfFile) + ' ' + getBaseName(acfFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string toLower(std::string s)
|
||||||
|
{
|
||||||
|
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c)
|
||||||
|
{
|
||||||
|
return std::tolower(c);
|
||||||
|
});
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
//! Extract ACF properties from an aircraft file
|
//! Extract ACF properties from an aircraft file
|
||||||
AcfProperties extractAcfProperties(const std::string &filePath)
|
AcfProperties extractAcfProperties(const std::string &filePath)
|
||||||
{
|
{
|
||||||
@@ -128,12 +139,15 @@ namespace BlackMisc
|
|||||||
std::string version;
|
std::string version;
|
||||||
std::string acf;
|
std::string acf;
|
||||||
std::getline(fs, i);
|
std::getline(fs, i);
|
||||||
|
i = toLower(i);
|
||||||
std::getline(fs, version);
|
std::getline(fs, version);
|
||||||
|
version = toLower(version);
|
||||||
std::getline(fs, acf);
|
std::getline(fs, acf);
|
||||||
|
acf = toLower(acf);
|
||||||
|
|
||||||
AcfProperties acfProperties;
|
AcfProperties acfProperties;
|
||||||
|
|
||||||
if (i == "I" && version.find("version") != std::string::npos && acf == "ACF")
|
if (i == "i" && version.find("version") != std::string::npos && acf == "acf")
|
||||||
{
|
{
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(fs, line))
|
while (std::getline(fs, line))
|
||||||
|
|||||||
Reference in New Issue
Block a user