//=========================================== // Lumina-DE source code // Copyright (c) 2013-2017, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "XDGMime.h" #include #include static QStringList mimeglobs; static qint64 mimechecktime; QString XDGMime::fromFileName(QString filename){ if(QFile::exists(filename) && QFileInfo(filename).isDir()){ return "inode/directory"; } //Convert a filename into a mimetype return findAppMimeForFile(filename.section("/",-1),false); } QStringList XDGMime::listFromFileName(QString filename){ //Convert a filename into a list of mimetypes (arranged in descending priority) return findAppMimeForFile(filename.section("/",-1),true).split("::::"); } QString XDGMime::toIconName(QString mime){ if(!mime.contains("/") || mime.isEmpty() ){ return "unknown"; } //not a mime type //Mime type to icon name mime.replace("/","-"); //translate to icon mime name return mime; } QStringList XDGMime::toFileExtensions(QString mime){ QStringList out; QStringList mimes = XDGMime::loadMimeFileGlobs2().filter(mime); for(int i=0; i" } //qDebug() << "Mime to Files:" << mime << out; return out; } // ==================== // BACKEND FUNCTIONS // ==================== QStringList XDGMime::systemMimeDirs(){ //Returns a list of all the directories where *.xml MIME files can be found QStringList appDirs = QString(getenv("XDG_DATA_HOME")).split(":"); appDirs << QString(getenv("XDG_DATA_DIRS")).split(":"); if(appDirs.isEmpty()){ appDirs << "/usr/local/share" << "/usr/share"; } //Now create a valid list QStringList out; for(int i=0; i