Fix model file name extensions
This commit is contained in:
committed by
Raphael Coeffic
parent
2d47701b72
commit
136d14af29
@@ -39,7 +39,8 @@ void RadioData::fixModelFilename(unsigned int index)
|
|||||||
{
|
{
|
||||||
ModelData & model = models[index];
|
ModelData & model = models[index];
|
||||||
QString filename(model.filename);
|
QString filename(model.filename);
|
||||||
bool ok = filename.endsWith(".bin");
|
const bool hasSDCard = Boards::getCapability(getCurrentFirmware()->getBoard(), Board::HasSDCard);
|
||||||
|
bool ok = hasSDCard ? filename.endsWith(".yml") : filename.endsWith(".bin");
|
||||||
if (ok) {
|
if (ok) {
|
||||||
if (filename.startsWith("model") && filename.mid(5, filename.length()-9).toInt() > 0) {
|
if (filename.startsWith("model") && filename.mid(5, filename.length()-9).toInt() > 0) {
|
||||||
ok = false;
|
ok = false;
|
||||||
@@ -54,7 +55,7 @@ void RadioData::fixModelFilename(unsigned int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
sprintf(model.filename, "model%d.bin", index+1);
|
sprintf(model.filename, "model%d.%s", index + 1, hasSDCard ? "yml" : "bin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,11 +69,12 @@ void RadioData::fixModelFilenames()
|
|||||||
|
|
||||||
QString RadioData::getNextModelFilename()
|
QString RadioData::getNextModelFilename()
|
||||||
{
|
{
|
||||||
|
const bool hasSDCard = Boards::getCapability(getCurrentFirmware()->getBoard(), Board::HasSDCard);
|
||||||
char filename[sizeof(ModelData::filename)];
|
char filename[sizeof(ModelData::filename)];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
bool found = true;
|
bool found = true;
|
||||||
while (found) {
|
while (found) {
|
||||||
sprintf(filename, "model%d.bin", ++index);
|
sprintf(filename, "model%d.%s", ++index, hasSDCard ? "yml" : "bin");
|
||||||
found = false;
|
found = false;
|
||||||
for (unsigned int i=0; i<models.size(); i++) {
|
for (unsigned int i=0; i<models.size(); i++) {
|
||||||
if (strcmp(filename, models[i].filename) == 0) {
|
if (strcmp(filename, models[i].filename) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user