From 3694deecf634ba14eef03367291b403ba2bea041 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Sun, 17 Aug 2014 20:37:15 +0200 Subject: [PATCH] Be resilient against zero or multiple "Categories" OPK metadata keys For zero keys, the OPK file itself would be parsed as a settings file. For multiple keys, all first categories would be appended to the path, leading to a much too deep directory. --- src/linkapp.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/linkapp.cpp b/src/linkapp.cpp index f231ee7..4f2f986 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -120,9 +120,8 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable) pos = opkMount.rfind('.'); opkMount = opkMount.substr(0, pos); - file = gmenu2x->getHome() + "/sections/"; - appTakesFileArg = false; + category = "applications"; while ((ret = opk_read_pair(opk, &key, &lkey, &val, &lval))) { if (ret < 0) { @@ -139,7 +138,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable) pos = category.find(';'); if (pos != category.npos) category = category.substr(0, pos); - file += category + '/' + opkMount; } else if ((!strncmp(key, "Name", lkey) && title.empty()) || !strncmp(key, ("Name[" + gmenu2x->tr["Lng"] + @@ -212,6 +210,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, string const& linkfile, bool deletable) #endif /* HAVE_LIBXDGMIME */ } + file = gmenu2x->getHome() + "/sections/" + category + '/' + opkMount; opkMount = (string) "/mnt/" + opkMount + '/'; edited = true; }