diff --git a/src/menu.cpp b/src/menu.cpp
index 1a52968..c57cd0b 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -818,21 +818,21 @@ void Menu::readLinks()
int correct = (i>sections.size() ? iSection : i);
string const& section = sections[correct];
- readLinksOfSection(GMENU2X_SYSTEM_DIR "/sections/" + section, i);
- readLinksOfSection(GMenu2X::getHome() + "/sections/" + section, i);
+ readLinksOfSection(
+ links[i], GMENU2X_SYSTEM_DIR "/sections/" + section, false);
+ readLinksOfSection(
+ links[i], GMenu2X::getHome() + "/sections/" + section, true);
}
orderLinks();
}
-void Menu::readLinksOfSection(std::string const& path, uint i)
+void Menu::readLinksOfSection(
+ vector& links, string const& path, bool deletable)
{
DIR *dirp = opendir(path.c_str());
if (!dirp) return;
- // Check whether link files in this directory could be deleted.
- bool deletable = access(path.c_str(), W_OK) == 0;
-
while (struct dirent *dptr = readdir(dirp)) {
if (dptr->d_type != DT_REG) continue;
string linkfile = path + '/' + dptr->d_name;
@@ -842,7 +842,7 @@ void Menu::readLinksOfSection(std::string const& path, uint i)
link->setSize(
gmenu2x->skinConfInt["linkWidth"],
gmenu2x->skinConfInt["linkHeight"]);
- links[i].push_back(link);
+ links.push_back(link);
} else {
delete link;
}
diff --git a/src/menu.h b/src/menu.h
index 0d91cdf..ca07315 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -89,7 +89,8 @@ private:
#endif
// Load all the links on the given section directory.
- void readLinksOfSection(std::string const& path, uint i);
+ void readLinksOfSection(std::vector& links,
+ std::string const& path, bool deletable);
void decSectionIndex();
void incSectionIndex();