mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 01:39:05 -05:00
Merge pull request #1762 from srcejon/fix_1760
Use QFileInfo to get file extension.
This commit is contained in:
commit
ffede33b12
@ -16,6 +16,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include "dsp/dspcommands.h"
|
#include "dsp/dspcommands.h"
|
||||||
#include "dsp/spectrumvis.h"
|
#include "dsp/spectrumvis.h"
|
||||||
@ -278,21 +279,14 @@ void FileSinkSink::applySettings(const FileSinkSettings& settings, bool force)
|
|||||||
|
|
||||||
if ((settings.m_fileRecordName != m_settings.m_fileRecordName) || force)
|
if ((settings.m_fileRecordName != m_settings.m_fileRecordName) || force)
|
||||||
{
|
{
|
||||||
QStringList dotBreakout = settings.m_fileRecordName.split(QLatin1Char('.'));
|
QFileInfo fileInfo(settings.m_fileRecordName);
|
||||||
|
QString extension = fileInfo.suffix();
|
||||||
if (dotBreakout.size() > 1) {
|
if (extension.isEmpty()) {
|
||||||
QString extension = dotBreakout.last();
|
fileRecordName.append(".sdriq");
|
||||||
|
} else if ((extension != "sdriq") && (extension != "wav")) {
|
||||||
if ((extension != "sdriq") && (extension != "wav")) {
|
fileRecordName.chop(extension.size());
|
||||||
dotBreakout.last() = "sdriq";
|
fileRecordName.append("sdriq");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dotBreakout.append("sdriq");
|
|
||||||
}
|
|
||||||
|
|
||||||
fileRecordName = dotBreakout.join(QLatin1Char('.'));
|
|
||||||
|
|
||||||
QString fileBase;
|
QString fileBase;
|
||||||
FileRecordInterface::RecordType recordType = FileRecordInterface::guessTypeFromFileName(fileRecordName, fileBase);
|
FileRecordInterface::RecordType recordType = FileRecordInterface::guessTypeFromFileName(fileRecordName, fileBase);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include "filerecordinterface.h"
|
#include "filerecordinterface.h"
|
||||||
|
|
||||||
@ -40,41 +41,32 @@ QString FileRecordInterface::genUniqueFileName(unsigned int deviceUID, int istre
|
|||||||
|
|
||||||
FileRecordInterface::RecordType FileRecordInterface::guessTypeFromFileName(const QString& fileName, QString& fileBase)
|
FileRecordInterface::RecordType FileRecordInterface::guessTypeFromFileName(const QString& fileName, QString& fileBase)
|
||||||
{
|
{
|
||||||
QStringList dotBreakout = fileName.split(QLatin1Char('.'));
|
QFileInfo fileInfo(fileName);
|
||||||
|
QString extension = fileInfo.suffix();
|
||||||
|
|
||||||
if (dotBreakout.length() > 1)
|
fileBase = fileName;
|
||||||
|
if (!extension.isEmpty())
|
||||||
{
|
{
|
||||||
QString extension = dotBreakout.last();
|
fileBase.chop(extension.size() + 1);
|
||||||
dotBreakout.removeLast();
|
|
||||||
|
|
||||||
if (extension == "sdriq")
|
if (extension == "sdriq")
|
||||||
{
|
{
|
||||||
if (dotBreakout.length() > 1) {
|
|
||||||
dotBreakout.removeLast();
|
|
||||||
}
|
|
||||||
|
|
||||||
fileBase = dotBreakout.join(QLatin1Char('.'));
|
|
||||||
return RecordTypeSdrIQ;
|
return RecordTypeSdrIQ;
|
||||||
}
|
}
|
||||||
else if (extension == "sigmf-meta")
|
else if (extension == "sigmf-meta")
|
||||||
{
|
{
|
||||||
fileBase = dotBreakout.join(QLatin1Char('.'));
|
|
||||||
return RecordTypeSigMF;
|
return RecordTypeSigMF;
|
||||||
}
|
}
|
||||||
else if (extension == "wav")
|
else if (extension == "wav")
|
||||||
{
|
{
|
||||||
fileBase = dotBreakout.join(QLatin1Char('.'));
|
|
||||||
return RecordTypeWav;
|
return RecordTypeWav;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileBase = fileName;
|
|
||||||
return RecordTypeUndefined;
|
return RecordTypeUndefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileBase = fileName;
|
|
||||||
return RecordTypeUndefined;
|
return RecordTypeUndefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user