From fcf093af29bba8ccb785b45edc195aa8f4c19526 Mon Sep 17 00:00:00 2001 From: mishas Date: Wed, 14 Mar 2007 19:45:35 +0000 Subject: [PATCH] implemented directory reading; next step is testing :) git-svn-id: file:///svnroot/simple-launcher/trunk@82 3ba93dab-e023-0410-b42a-de7732cf370a --- simple-launcher.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/simple-launcher.cc b/simple-launcher.cc index ceddd7c..b9c894c 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -19,6 +19,8 @@ #include #include +#include + #include #include @@ -210,6 +212,27 @@ void SimpleLauncherApplet::saveConfig() { } void SimpleLauncherApplet::processDirectory(const std::string& dirname) { + DIR *dir = opendir(dirname.c_str()); + + if (dir != NULL) { + const std::string namePrefix = dirname + "/"; + std::string shortName; + std::string desktopExtension = ".desktop"; + const dirent *file; + + while ((file = readdir(dir)) != 0) { + shortName = file->d_name; + if ((shortName == ".") || (shortName == "..")) { + continue; + } + + if ((shortName.length() >= desktopExtension.length()) && (shortName.compare(shortName.length() - desktopExtension.length(), desktopExtension.length(), desktopExtension) == 0)) { + addItem(namePrefix+shortName, false); + } + } + + closedir(dir); + } } bool SimpleLauncherApplet::initWidget() { -- 1.7.9.5