@@ -80,10 +80,7 @@ class CDesktopEntry : public IFinderResult {
8080 uint32_t m_frequency = 0 ;
8181};
8282
83- static constexpr std::array<const char *, 3 > DESKTOP_ENTRY_PATHS = {" /usr/local/share/applications" , " /usr/share/applications" , " ~/.local/share/applications" };
84-
85- //
86- static std::string resolvePath (std::string p) {
83+ static std::filesystem::path resolvePath (const std::string& p) {
8784 if (p[0 ] != ' ~' )
8885 return p;
8986
@@ -92,9 +89,11 @@ static std::string resolvePath(std::string p) {
9289 if (!HOME )
9390 return " " ;
9491
95- return HOME + p.substr (1 );
92+ return std::filesystem::path ( HOME ) / p.substr (2 );
9693}
9794
95+ static const std::array<std::filesystem::path, 3 > DESKTOP_ENTRY_PATHS = {" /usr/local/share/applications" , " /usr/share/applications" , resolvePath (" ~/.local/share/applications" )};
96+
9897CDesktopFinder::CDesktopFinder () : m_inotifyFd(inotify_init()), m_entryFrequencyCache(makeUnique<CEntryCache>(" desktop" )) {
9998 const auto ENV = getenv (" XDG_DATA_DIRS" );
10099 if (!ENV )
@@ -103,8 +102,8 @@ CDesktopFinder::CDesktopFinder() : m_inotifyFd(inotify_init()), m_entryFrequency
103102 CConstVarList paths (ENV , 0 , ' :' , false );
104103
105104 for (const auto & p : paths) {
106- const auto PTH = std::string{p} + " / applications" ;
107- std::error_code ec;
105+ const std::filesystem::path PTH = std::filesystem::path (p) / " applications" ;
106+ std::error_code ec;
108107 if (!std::filesystem::exists (PTH , ec) || ec)
109108 continue ;
110109
0 commit comments