summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-02-17 22:09:25 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-02-17 22:09:25 +0100
commit762d7367f5f74f877ec75986e19fc9d46eef5164 (patch)
treec5ce3f772f278f752ea8c08c2281c9a0b89bddaf /apt-pkg/policy.cc
parentac83edae692c6c7dda7e41e3b27f5cbff0473629 (diff)
parent07f2526e45f9978201817237745727db6177c29a (diff)
merged from debian-sid
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc37
1 files changed, 3 insertions, 34 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 81fdb0431..f9901bc9a 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -27,14 +27,12 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
-
+
#include <apti18n.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <algorithm>
#include <iostream>
#include <sstream>
/*}}}*/
@@ -282,36 +280,7 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
return true;
}
- 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, "pref", true, true);
// Read the files
for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)