summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/configuration.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-01-03 19:37:34 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-01-03 19:37:34 +0100
commit52643bec17df4e36a9bd27183886e2c0c7a8ebd8 (patch)
tree6a989a09519b7c706404c4dcd7bb2b6ed7ab6883 /apt-pkg/contrib/configuration.cc
parent6355a02fbfa1cffa9291095ede32c35737ed7419 (diff)
Add a GetListOfFilesInDir() helper method which replaces the old
code copies used to load the various parts-files
Diffstat (limited to 'apt-pkg/contrib/configuration.cc')
-rw-r--r--apt-pkg/contrib/configuration.cc39
1 files changed, 2 insertions, 37 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index ff49ce857..89aa854a3 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -22,14 +22,8 @@
#include <apti18n.h>
#include <vector>
-#include <algorithm>
#include <fstream>
#include <iostream>
-
-#include <stdio.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
using namespace std;
/*}}}*/
@@ -837,37 +831,8 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
/* */
bool ReadConfigDir(Configuration &Conf,const string &Dir,bool const &AsSectional,
unsigned const &Depth)
-{
- DIR *D = opendir(Dir.c_str());
- if (D == 0)
- return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
-
- vector<string> List;
-
- for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
- {
- if (Ent->d_name[0] == '.')
- continue;
-
- // Skip bad file names ala run-parts
- const char *C = Ent->d_name;
- for (; *C != 0; C++)
- if (isalpha(*C) == 0 && isdigit(*C) == 0 && *C != '_' && *C != '-')
- break;
- if (*C != 0)
- continue;
-
- // Make sure it is a file and not something else
- string File = flCombine(Dir,Ent->d_name);
- struct stat St;
- if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
- continue;
-
- List.push_back(File);
- }
- closedir(D);
-
- sort(List.begin(),List.end());
+{
+ vector<string> const List = GetListOfFilesInDir(Dir, "", true);
// Read the files
for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)