mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 19:03:44 +02:00
Don't use file system write permissions to determine "deletable"
Instead, consider the installation location non-deletable and the home directory deletable. This makes the "deletable" property follow the purpose of the directory rather than its implementation details.
This commit is contained in:
parent
fe790b1c8d
commit
5805d7889f
14
src/menu.cpp
14
src/menu.cpp
@ -818,21 +818,21 @@ void Menu::readLinks()
|
|||||||
int correct = (i>sections.size() ? iSection : i);
|
int correct = (i>sections.size() ? iSection : i);
|
||||||
string const& section = sections[correct];
|
string const& section = sections[correct];
|
||||||
|
|
||||||
readLinksOfSection(GMENU2X_SYSTEM_DIR "/sections/" + section, i);
|
readLinksOfSection(
|
||||||
readLinksOfSection(GMenu2X::getHome() + "/sections/" + section, i);
|
links[i], GMENU2X_SYSTEM_DIR "/sections/" + section, false);
|
||||||
|
readLinksOfSection(
|
||||||
|
links[i], GMenu2X::getHome() + "/sections/" + section, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
orderLinks();
|
orderLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::readLinksOfSection(std::string const& path, uint i)
|
void Menu::readLinksOfSection(
|
||||||
|
vector<Link*>& links, string const& path, bool deletable)
|
||||||
{
|
{
|
||||||
DIR *dirp = opendir(path.c_str());
|
DIR *dirp = opendir(path.c_str());
|
||||||
if (!dirp) return;
|
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)) {
|
while (struct dirent *dptr = readdir(dirp)) {
|
||||||
if (dptr->d_type != DT_REG) continue;
|
if (dptr->d_type != DT_REG) continue;
|
||||||
string linkfile = path + '/' + dptr->d_name;
|
string linkfile = path + '/' + dptr->d_name;
|
||||||
@ -842,7 +842,7 @@ void Menu::readLinksOfSection(std::string const& path, uint i)
|
|||||||
link->setSize(
|
link->setSize(
|
||||||
gmenu2x->skinConfInt["linkWidth"],
|
gmenu2x->skinConfInt["linkWidth"],
|
||||||
gmenu2x->skinConfInt["linkHeight"]);
|
gmenu2x->skinConfInt["linkHeight"]);
|
||||||
links[i].push_back(link);
|
links.push_back(link);
|
||||||
} else {
|
} else {
|
||||||
delete link;
|
delete link;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,8 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load all the links on the given section directory.
|
// Load all the links on the given section directory.
|
||||||
void readLinksOfSection(std::string const& path, uint i);
|
void readLinksOfSection(std::vector<Link*>& links,
|
||||||
|
std::string const& path, bool deletable);
|
||||||
|
|
||||||
void decSectionIndex();
|
void decSectionIndex();
|
||||||
void incSectionIndex();
|
void incSectionIndex();
|
||||||
|
Loading…
Reference in New Issue
Block a user