shared: Move textfile detector to common
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <QSqlError>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include <QMimeDatabase>
|
||||
#include "looqsgeneralexception.h"
|
||||
#include "common.h"
|
||||
#include "dbmigrator.h"
|
||||
@ -178,3 +179,25 @@ QStringList Common::excludedPaths()
|
||||
}
|
||||
return ::excludedPaths;
|
||||
}
|
||||
|
||||
bool Common::isTextFile(QFileInfo fileInfo)
|
||||
{
|
||||
/* TODO: This is not sandboxed yet ... */
|
||||
QMimeDatabase mimeDatabase;
|
||||
QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileInfo);
|
||||
if(mimeType.name().startsWith("text/"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(QString &str : mimeType.allAncestors())
|
||||
{
|
||||
if(str.startsWith("text/"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Посилання в новій задачі
Block a user