From 52643bec17df4e36a9bd27183886e2c0c7a8ebd8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 3 Jan 2010 19:37:34 +0100 Subject: Add a GetListOfFilesInDir() helper method which replaces the old code copies used to load the various parts-files --- apt-pkg/sourcelist.cc | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'apt-pkg/sourcelist.cc') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 4b3abe918..929259961 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -17,13 +17,6 @@ #include #include - -// CNC:2003-03-03 - This is needed for ReadDir stuff. -#include -#include -#include -#include -#include /*}}}*/ using namespace std; @@ -322,41 +315,7 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const /* */ bool pkgSourceList::ReadSourceDir(string Dir) { - DIR *D = opendir(Dir.c_str()); - if (D == 0) - return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); - - vector List; - - for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) - { - if (Ent->d_name[0] == '.') - continue; - - // CNC:2003-12-02 Only accept .list files as valid sourceparts - if (flExtension(Ent->d_name) != "list") - 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 != '-' && *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 const List = GetListOfFilesInDir(Dir, "list", true); // Read the files for (vector::const_iterator I = List.begin(); I != List.end(); I++) -- cgit v1.2.3