static int _GetAppList( const unicode_t* fileName, ccollect<AppNode*>& list ) { if ( !mimeDb.ptr() ) { if ( FileIsExist( "/usr/share/mime/globs" ) ) { mimeDb = new MimeDB( "/usr/share/mime/" ); } else { mimeDb = new MimeDB( "/usr/local/share/mime/" ); } } if ( !appDb.ptr() ) { if ( DirIsExist( "/usr/share/applications" ) ) { appDb = new AppDB( "/usr/share/applications/" ); } else { appDb = new AppDB( "/usr/local/share/applications/" ); } } if ( !userDefApp.ptr() ) { const char* home = getenv( "HOME" ); if ( home ) { userDefApp = new AppDefListFile( carray_cat<char>( home, "/.local/share/applications/mimeapps.list" ).data() ); } } mimeDb->Refresh(); appDb->Refresh(); if ( userDefApp.ptr() ) { userDefApp->Refresh(); } ccollect<int> mimeList; if ( mimeDb->GetMimeList( fileName, mimeList ) ) { int i; std::unordered_map<int, bool> hash; for ( i = 0; i < mimeList.count(); i++ ) { ccollect<int> appList; if ( userDefApp.ptr() ) { userDefApp->GetAppList( mimeList[i], appList ); } appDb->GetAppList( mimeList[i], appList ); for ( int j = 0; j < appList.count(); j++ ) { bool Exists = hash.find( appList[j] ) != hash.end(); if ( !Exists ) { hash[appList[j]] = true; AppNode* p = appDb->GetApp( appList[j] ); if ( p && p->exec.data() ) { list.append( p ); } } } } } return list.count(); }